Objects and behaviour
What is object identity?
On this page
Identity distinguishes one particular object from every other live object. In Python, a = []; b = []; c = a gives a == b, a is not b and a is c. Appending through c changes what a sees. Use identity when aliasing matters and value equality when contents determine the answer.
Worked example
Pythonleft = {"job": 17}
right = {"job": 17}
alias = left
assert left == right and left is not right
alias["job"] = 18
assert left["job"] == 18 and right["job"] == 17Explore class relationships in the OOP Playground