None :)

Mark Jackson mjackson at wc.eso.mc.xerox.com
Wed Apr 25 10:05:46 EDT 2001


Michael Hudson <mwh21 at cam.ac.uk> writes:
> Hans Kristian Ruud <hans at inenco.no> writes:
> 
> > When an element in a sequence s is None,
> > max (s) will return None:
> 
> All numeric types compare lower than all other types.  So
> max([0,1L,2.0,""]) is "", for instance.
> 
> http://python.sourceforge.net/devel-docs/ref/comparisons.html
> 
> has the juice, including the statement that this behaviour is "likely
> to change" in the future.

It's probably worth reinforcing that warning with the observation that
this behavior has, in fact, changed in the past.  For example, None used
to compare lower:

Python 1.4 (Nov 17 1997)  [GCC 2.7.2.2]
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> s = [1.4, 2.5, None, 4354549999L]
>>> max(s)
4354549999L
>>> min(s)
>>> 

And my favorite example:  through 1.5.1, if

>>> a = 2
>>> b = []
>>> c = 1L

then

>>> a < b < c < a

returned 1 (true).

one-person's-absurd-is-another-person's-appealingly-surreal-ly y'rs,

-- 
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
    Popular memory may be short, but it is nothing
    compared with the amnesia of experts.
			- Adam Gopnik





More information about the Python-list mailing list