MemotivaProperties, descriptors, and slots

When should you use a property versus a regular attribute?

Properties, descriptors, and slots

Audio flashcard · 0:15

Nortren·

When should you use a property versus a regular attribute?

0:15

Use a regular attribute when there is no need for computation, validation, or side effects. Use a property when access requires logic, when you want to compute the value on demand, when you need to maintain backward compatibility while adding behavior, or when an attribute should be read-only.
docs.python.org