Consider this Python: Surprised? That’s because “is” is the wrong comparison: • == asks: are these the same value?• is asks: are these the same object? You almost never care about question #2. And so, should rarely use “is”.
It’s really tempting, when you first start to use Python, to use “is” rather than “==”. It’s a bit more readable, and it feels like it should just work, especially when you’re dealing with integers. In a language that uses “or” and “and” instead of “||” and “&&”, it seems logical to use “is” instead…