I'm just trying to get the addresses of variables in python and came across something odd.
I have assigned some numbers to a variable and checking the Equality and Identity of those variables.
>>>a=-10
>>>a is -10
Output:
False
>>>a=-5
>>>a is -5
Output:
True
>>>a=256
>>>a is 256
Output:
True
>>>a=257
>>>a is 257
Output:
False
I'm just curious what's happening behind the scenes in range -5
to 256
.
Can someone please explain.
It's something like the one mentioned here - https://ubuntuforums.org/archive/index.php/t-1848655.html
I'm using:
Python: 3.7.5
Ubuntu: 18.04