I (incorrectly?) used \'is not\' in a comparison and found this curious behavior:
>>> a = 256
>>> b = int(\'256\')
>>> c = 300
>>
Int is an object in python, and python caches small integer between [-5,256] by default, so where you use int in [-5,256], they are identical.
a = 256
b = 256
a is b # True
If you declare two integers not in [-5,256], python will create two objects which are not the same(though they have the same value).
a = 257
b = 257
a is b # False
In your case, using !=
instead to compare the value is the right way.
a = 257
b = 257
a != b # False