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

Georg Brandl g.brandl at gmx.net
Fri Oct 15 19:27:10 CEST 2010

Am 15.10.2010 19:13, schrieb Ron Adam:

> [Tal also says]
>> As Guido mentioned, there is never a reason to do max(value) where
>> value is not an iterable.
> Well, you can always avoid doing it, but that doesn't mean it wouldn't be 
> nice to have sometimes.  Take a look at the following three coroutines that 
> do the same exact thing.  Which is easier to read and which would be 
> considered the more Pythonic.
> def xmin(*args, **kwds):
>      # Allow min to work with a single non-iterable value.
>      if len(args) == 1 and not hasattr(args[0], "__iter__"):
>          return min(args, **kwds)
>      else:
>          return min(*args, **kwds)

I don't understand this function.  Why wouldn't you simply always call

   return min(args, **kwds)



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