There’s a difference in meaning between identical and equal. This distinction is the same distinction between is and == operator in Python.
The
==operator compares by checking for equality of values.The
isoperator, however, compares by checking for equality of identities (they point to the same memory address).
Suppose you have two lists.
a = [1, 2, 3]
b = [1, 2, 3]
a is b # False (check equality by identity)
a == b # True (check equality by value)
One way to determine whether a is b is by using the built-in id function which will return the memory address that the variable name points to.
id(a) == id(b) # False
Top comments (0)