Possible Duplicate:
Python “is” operator behaves unexpectedly with integers
Today I tried to debug my project and after a few hours of analysing I'd got this:
>>> (0-6) is -6
False
but,
>>> (0-5) is -5
True
Could you explain to me, why? Maybe this is some kind of bug or very strange behavior.
> Python 2.7.3 (default, Apr 24 2012, 00:00:54) [GCC 4.7.0 20120414 (prerelease)] on linux2
>>> type(0-6)
<type 'int'>
>>> type(-6)
<type 'int'>
>>> type((0-6) is -6)
<type 'bool'>
>>>