Python is vs ==: Object identity and value equality

Consider this Python:

>>> x = 100000
>>> y = 100000
>>> x is y
False

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”.