We rarely think about the dot "." between our objects and their fields, but there are quite a lot of things that happen every time we use one in Python. This talk will explore the details of what happens, how the descriptor protocol works, and how it can be used to alter the Python object model.
Actions to be explored:
- The instance __dict__ is checked.
- The class __dict__ is checked.
- The base classes __dicts__ are checked.
- __getattr__ runs.
- __getattribute__ runs.
- The __get__ method on the object in the class __dict__ is called.
- The object in the class __dict__ is checked for a __set__ method.
- raise AttributeError
Most of the talk will focus on 6 & 7 to explain the Descriptor protocol. Examples will include altering method binding and property behaviors, as well as supporting method implementation reuse via Descriptors.