© Jacob Zimmerman 2018
Jacob ZimmermanPython Descriptorshttps://doi.org/10.1007/978-1-4842-3727-4_11

11. Reusing the Wheel

Jacob Zimmerman1 
(1)
New York, USA
 

Whenever possible and sensible, one should try to avoid reinventing the wheel. This chapter goes over a set of classes to use as superclasses and strategies to help build new descriptors a little faster. Only barebones code is presented here; the full code examples are in the library.

Storage Solutions

The first code examples cover storage “strategies” (which I’m calling “solutions”) that a descriptor can use for its storage. These strategies can be hard-coded into new descriptors or be passed into the descriptor’s initializer to be chosen on a case-by-case basis. Only two basic strategies will ...

Get Python Descriptors: Understanding and Using the Descriptor Protocol now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.