Compare if two variables reference the same object in python

That’s what is is for.

In the example, x is y returns True because it is the same object while x is z returns False because it are different objects (which happen to hold identical data).

Leave a Comment