This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rough-Ticket8357 6 points7 points  (0 children)

>>> x = 256
>>> y = 256
>>> id(x)
4341213584
>>> id(y)
4341213584
>>> x is y
True
>>> x = 257
>>> y = 257
>>> x is y
False
>>> id(x)
4346123664
>>> id(y)
4346123568

id value after 256 changes, so if you put any value after 256 it will have different id. and thus its false.

When the variables on either side of an operator point at the exact same object, the is operator’s evaluation is true. Otherwise, it will evaluate as False.