What's the value of "None" between 2.1.1 and 1.5.2

Delaney, Timothy tdelaney at avaya.com
Thu Nov 29 22:16:29 EST 2001


> From: ozonehole2k at yahoo.com [mailto:ozonehole2k at yahoo.com]
>
> In the new machine:
> Python 2.1.1 (#1, Nov 11 2001, 18:19:24) 
> [GCC 2.95.4 20011006 (Debian prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> a=[3,4,5,7,None,0.2,-4]
> >>> print min(a)
> None
> >>> print max(a)
> 7
> 
> Python 1.5.2 (#1, Sep 30 2000, 18:08:36)  [GCC 2.95.3 19991030
> (prerelease)] on linux-i386
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> a=[3,4,5,7,None,0.2,-4]
> >>> print min(a)
> -4
> >>> print max(a)
> None
> >>> 
> 
> 
> It seems to me that "None" means -Inf in 2.2.1 but means "Inf" in
> 1.5.2.  Why do the Python guys change this assumption?  In my
> calculations, I use "None" to indicate very large estimation error. 
> Is there any formal symbol for this?  I don't really want to fix this
> type of bug again whenever Python upgrades....

Your assumptions are wrong. You should not assume - you should use the
reference.

Instances of different types/classes will compare in an arbitrary (but
consistent) order (assuming they can compare at all). The order of None
compared to other types changed between releases. It is allowed to do this.

You cannot rely on the comparison order of different types unless the types
specifically support comparing with each other.

Tim Delaney




More information about the Python-list mailing list