Lesson 23 — Descriptors
Control attribute access
A descriptor is a class with get/set that manages another class's attribute. set runs on every assignment, so it can validate.
Why it matters: it is how ORMs and @property work under the hood.
Finish __set__: raise ValueError("must be >= 0") for negatives, otherwise store the value with setattr.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based Python Intermediate courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for Python Intermediate books — check the publication year so the examples match current versions.
Search Amazon →