Properties, descriptors & immutability
P28.data-modelling.03 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Dunder methods & the data model
Where next?
Go up a level
P28.data-modelling.03 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Dunder methods & the data model
Go up a level
Attributes don't have to be plain slots. A property turns attribute access
into method calls (computed values, validation on set); a descriptor is the
reusable machinery behind properties, letting you factor a validation rule out
of one class and share it across many; and __slots__ trades per-instance
flexibility for memory and a fixed attribute set. Together they are how you make
an object correct by construction.
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 your notes...