Browse OOP reference
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

Python
left = {"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"] == 17

Python data model

Explore class relationships in the OOP Playground

What is an object?What are value objects?Is object-oriented programming obsolete?

All OOP questions

Search ObjectFAQ