Question about 'None'

Francis Girard francis.girard at free.fr
Thu Jan 27 15:06:22 EST 2005


Le jeudi 27 Janvier 2005 20:16, Steven Bethard a écrit :
> flamesrock wrote:
> > The statement (1 > None) is false (or any other value above 0). Why is
> > this?
>
> What code are you executing?  I don't get this behavior at all:
>
> py> 100 > None
> True
> py> 1 > None
> True
> py> 0 > None
> True
> py> -1 > None
> True
> py> -100 > None
> True
>

Wow ! What is it that are compared ? I think it's the references (i.e. the 
adresses) that are compared. The "None" reference may map to the physical 0x0 
adress whereas 100 is internally interpreted as an object for which the 
reference (i.e. address) exists and therefore greater than 0x0.

Am I interpreting correctly ?

> > (The reason I ask is sortof unrelated. I wanted to use None as a
> > variable for which any integer, including negative ones have a greater
> > value so that I wouldn't need to implement any tests or initializations
> > for a loop that finds the maximum of a polynomial between certain x
> > values. Anything is greater than nothing, no?)
>
> Yup, that's the behavior I get with None.
>
> Steve




More information about the Python-list mailing list