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

Ron Adam rrr at ronadam.com
Sat Oct 16 07:31:36 CEST 2010


On 10/15/2010 03:52 PM, Georg Brandl wrote:
> Am 15.10.2010 22:00, schrieb Ron Adam:
>
>>> (Notice the same will hold for min() but at least you know that min(x)
>>> considers x as an iterable and complains if it isn't)
>>
>> Yes
>>
>> There doesn't seem to be a way to generalize min/max in a way to handle all
>> the cases without knowing the context.
>
> I give up.  You see an issue where there is none.

Sorry for the delay, I was away for the day...

Thanks for trying George, it really wasn't an issue.  I was thinking about 
it from the point of view of, would it be possible to make min and max 
easier to use in indirect ways.

As I found out, those functions depend on both the number of arguments, and 
the context they are used in, to do the right thing.  Change either and you 
may get unexpected results.

In the example where *args was used... I had left out the function def of 
min(*args, **kwds) where you would have saw that args, was just unpacking 
the arguments, and not the list object being passed to min.  My mistake.

Cheers,
    Ron







More information about the Python-ideas mailing list