juniorPython
The 'is' vs '==' operators
Updated May 4, 2026
Short answer
'is' checks identity; '==' checks equality.
Deep explanation
'==' checks if values are equal. 'is' checks if both variables point to the exact same object in memory (id()).
Real-world example
Using 'var is None' which is the Pythonic way to check for nullity.
Common mistakes
- Using 'is' to compare small integers, which might work due to interning but is logically incorrect.
Follow-up questions
- What is id()?