Track 11 · Lesson 6 of 12
Encapsulation and properties
Keep an object's data valid with the _internal convention, @property getters, validating setters and computed attributes.
You will be able to
- Explain encapsulation and the leading-underscore convention for internal attributes
- Turn an attribute into a @property so reading it runs code
- Write a setter that validates new values, and reuse it from __init__
- Provide read-only computed attributes such as totals and conversions
Included with a Formula Quest membership
It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.
View Formula Quest memberships
Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.