negative numbers are not equal...

ariel ledesma fayuca at gmail.com
Thu Aug 14 16:18:55 EDT 2008


hello guys

i just ran into this when comparing negative numbers, they start 
returning False from -6 down, but only when comparing with 'is'

 >>> m = -5
 >>> a = -5
 >>> m is a
True
 >>> m = -6
 >>> a = -6
 >>> m is a
False
 >>> m == a
True

i read that 'is' compares if they are really the same object, but i 
don't that's it because then why does -5 return True?
of course i could only use == to compare, but still, what am i missing here?
thanks in advance

ariel




More information about the Python-list mailing list