== or is? Object EQUALITY and IDENTITY in Python

Опубликовано: 01 Ноябрь 2024
на канале: Python for Everyone
747
32

This video shows the difference between object equality (==) and object identity (is) and when to use one or the other.

C H A P T E R S
0:33 Comparing equality and identity
1:20 Difference between integers and custom classes
1:28 Object equality
1:56 Implement dunder equals (__eq__) to support equality comparison in your class
2:19 Identity check
3:09 The object identity is read-only
3:30 Singletons and identity
4:45 When to compare equality and when to compare identity
4:47 Edge cases

M Y O N L I N E T R A I N I N G
🎓Like my style of teaching? Try free chapters of my online courses: https://pythonforeveryone.com

L I N K S I N T H E V I D E O
Sorting algorithm in Python: https://en.wikipedia.org/wiki/Timsort

#pythonforeveryone #programming #python