by Peter Inglesby for EuroPython 2012
Descriptors play a key role in the implementation of Python itself, and they are quite often used in library code. However, despite their ubiquity, they are often poorly understood.
The Descriptor Protocol generalises attribute access. We’ll begin with a brief review of what happens when you look up an attribute on an object (ie call “someobject.someattribute") before looking at how descriptors allow callbacks to be run when attributes are got or set. We’ll end with a whirlwind tour of some of the ways descriptors are used in the implementation of Python itself, and how these can make your code more concise and powerful.
This talk will be suitable for those familiar with object oriented programming in Python.