Equality versus identity in Python

Опубликовано: 18 Март 2026
на канале: Python Morsels
606
34

Equality checks whether two objects represent the same value. Identity checks whether two variables point to the same object.

Equality is checked with "==" and identity is checked with "is".

Article at https://pym.dev/equality-vs-identity/

More #Python screencasts at https://pym.dev/screencasts/

00:00 The equality operator in Python
00:45 The "is" operator in Python
01:34 How equality and identity work differently?
02:21 Inequality and non-identity operators
02:47 Where are identity checks used?
03:28 Equality vs. Identity