June 2017
Beginner
352 pages
8h 39m
English
Let's contrast that behavior with a test for value-equality, or equivalence. We'll create two identical lists:
>>> p = [4, 7, 11]>>> q = [4, 7, 11]>>> p == qTrue>>> p is qFalse
Here we see that p and q refer to different objects, but that the objects they refer to have the same value:

As you would expect when testing for value-equality, an object should always be equivalent to itself:
>>> p == pTrue
Value-equality and identity are fundamentally different notions of "equality", and it's important to keep them separate ...
Read now
Unlock full access