["python"]
Is it better to use "is" or "==" for number comparison in Python?

Is it better to use the "is" operator or the "==" operator to compare two numbers in Python? Examples: >>> a = 1 >>> a is 1 True >>> a == 1 True >>> a is 0 False >>> a == 0 False
Use ==. Sometimes, on some python implementations, by coincidence, integers from -5 to 256 will work with is (in CPython implementations for instance). But don't rely on this or use it in real programs.