well, i'm glad i stumbled upon this detail early on (i only had to fix
about one page of code)... i'll just stick to 'is' when it concerns
checking if it is the *same* object (memorywise) instead of an
*equivalent* one...
just before wrapping up, the special methods __eq__ and __ne__ are
called
Christian Heimes wrote:
You are getting the result because Python optimized small integers.
See http://svn.python.org/projects/python/trunk/Objects/intobject.c
Integers between -5 and +256 are singletons as are some other objects
like strings with one element or empty tuples. You must not rel
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