[Python-ideas] Break the dominance of boolean values in boolean context

Devin Jeanpierre jeanpierreda at gmail.com
Thu Sep 15 01:07:03 CEST 2011


> Even if it did, it wouldn't necessarily make sense for max() to
> return it. max(s) means "the largest member of set s", and for it
> to return something that wasn't a member of s would be perverse.

Perverse and also wrong. Perhaps you want an infimum/supremum function?

Devin

On Wed, Sep 14, 2011 at 6:45 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Terry Reedy wrote:
>
>> You should turn the question around, any([]) returns the identity element
>> for any(), so why does't max([])?  Because Python does not have an
>> artificial universal minimum object.
>
> Even if it did, it wouldn't necessarily make sense for max() to
> return it. max(s) means "the largest member of set s", and for it
> to return something that wasn't a member of s would be perverse.
>
> In every case I've encountered where there's a possibility of
> min() or max() being applied to an empty collection, the empty
> state had to be treated as a special case anyway. So it's just
> as easy to test for the empty case before calling min() or max().
>
> --
> Greg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list