returning True, False or None

Francis Girard francis.girard at free.fr
Sun Feb 6 15:58:08 EST 2005


I think it is evil to do something "at your own risk" ; I will certainly not 
embark some roller coaster at my own risk.

I also think it is evil to scan the whole list (as "max" ought to do) when 
only scanning the first few elements would suffice most of the time.

Regards

Francis Girard

Le vendredi 4 Février 2005 21:13, Steven Bethard a écrit :
> Fredrik Lundh wrote:
> > Steven Bethard wrote:
> >> Raymond Hettinger wrote:
> >>> return max(lst)
> >>
> >> Very clever!  Thanks!
> >
> > too clever.  boolean > None isn't guaranteed by the language
> > specification:
>
> Yup.  I thought about mentioning that for anyone who wasn't involved in
> the previous thread discussing this behavior, but I was too lazy.  ;)
> Thanks for pointing it out again.
>
> This implementation detail was added in Python 2.1a1, with the following
> note[1]:
>
> "The outcome of comparing non-numeric objects of different types is
> not defined by the language, other than that it's arbitrary but
> consistent (see the Reference Manual).  An implementation detail changed
> in 2.1a1 such that None now compares less than any other object.  Code
> relying on this new behavior (like code that relied on the previous
> behavior) does so at its own risk."
>
> Steve
>
> [1] http://www.python.org/2.1/NEWS.txt




More information about the Python-list mailing list