Dunder methods & the data model
P28.data-modelling.02 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Records: class vs dataclass vs namedtuple
Where next?
Later in Data Modelling
Go up a level
P28.data-modelling.02 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Records: class vs dataclass vs namedtuple
Later in Data Modelling
Go up a level
Python's data model is the set of dunder (double-underscore) methods that
let your objects plug into the language's syntax and built-ins: ==, <,
hash(), repr(), in, with, and more. Implement them well and your types
feel native; implement them carelessly and you get subtle bugs.
This ladder builds two value objects — a colour and a version — and wires them into equality, hashing, and ordering.
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
Loading exercise…
Loading exercise…
Loading exercise…
Loading your notes...