Practical introduction to descriptors
- Level:
- intermediate
- Room:
- club b
- Start:
- Duration:
- 90 minutes
Abstract
Descriptors are not black magic and this practical tutorial will show you that. In fact, you use descriptors every day and you don't even know it!
Through a series of practical, hands-on exercises, you will learn
- how to create a descriptor;
- how to use the dunder methods
__get__
,__set__
, and__set_name__
; - what the descriptor protocol is; and
- where descriptors show up in day-to-day Python code.
Description
The expected Python level for participants is “intermediate”.
In practice, if you are comfortable with using the built-in property
and if you have used dunder methods before, you should be fine.
This tutorial is based off of an article I wrote about descriptors.
All materials can be accessed from this GH repo.