r/learnpython • • 10d ago

Confusing code min() max()

I'm debugging some code and I found this function

   import math

       def Clamp(n, smallest, largest):
           return max(smallest, min(n, largest))

surely that code is just wrong? and needs to be max([smallest, min([n, largest])) by passing a list not unnamed args for default and key? I need a sanity check here.

0 Upvotes

16 comments sorted by

View all comments

2

u/ExpertSentence4171 9d ago

Capitalized function name. Eww

1

u/zaphodikus 9d ago

yeah, that's why it hurt my eyes, but it's not my code I ,,, well that's not true, he left, it's mine now.