How do I check if two variables reference the same object in Python? How do I check if two variables reference the same object in Python? python python

How do I check if two variables reference the same object in Python?


You can use is to check if two objects have the same identity.

>>> x = [1, 2, 3]>>> y = [1, 2, 3]>>> x == yTrue>>> x is yFalse