The "is" operator compares objects by identity, not value. It would be
valid for a Python implementation to have two different int objects
with value 2 (although in practice CPython doesn't).
Recent Python versions detect this with a warning:
SyntaxWarning: "is" with a literal. Did you mean "=="?
The "is" operator compares objects by identity, not value. It would be valid for a Python implementation to have two different int objects with value 2 (although in practice CPython doesn't).
Recent Python versions detect this with a warning: