[Python-ideas] [Python-Dev] minmax() function returning (minimum, maximum) tuple of a sequence

Georg Brandl g.brandl at gmx.net
Fri Oct 15 21:25:27 CEST 2010

Am 15.10.2010 20:09, schrieb Ron Adam:
>> I don't understand this function.  Why wouldn't you simply always call
>>     return min(args, **kwds)
>> ?
> Because it would always interpret a list of values as a single item.
> This function looks at args and if its a single value without an "__iter__" 
> method, it passes it to min as min([value], **kwds) instead of min(value, 
> **kwds).
> Another way to do this would be to use a try-except...
>      try:
>           return min(*args, **kwds)
>      except TypeError:
>           return min(args, **kwds)

And that's just gratuitous.  If you have the sequence of items to compare
already as an iterable, there is absolutely no need to unpack them using


Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.

More information about the Python-ideas mailing list