Descriptors in Python

To learn about descriptors I started with the best out there Raymond Hittinger’s “Descriptors HowTo Guide”. There, I completed “Complete Practical Example” about using a validator as a descriptor and how to use an “abstract base class” with it. In his tutorial I learned how to: • Descriptor as validator and how to use “abstract base class” with it • Manage attribute and logging module • Descriptor protocol (__get__(), __set__(), __delete()) • Descriptor invocation from instance, class, super • Properties, bound methods, classes methods and __slots__ based on descriptor protocol You can find this tutorial at · https://docs.python.org/3/howto/descriptor.html#id1 Then, I read the book “Python Descriptors: Understanding and Using the Descriptor Protocol” written by Jacob Zimmerman. He is a certified Java programmer and a Python and Kotlin enthusiast. Additionally, to what Raymond Hittinger’s “Descriptors HowTo Guide” explains, this book goes into more examples of how descriptors are used. In his book I learned how to: • Use of descriptors for data encapsulation • Use of descriptors for reuse of read/write patterns • Use of descriptors for lazily instantiating an attribute • Use of descriptors for validation • Use of descriptors for triggering actions • Use of descriptors for lazily instantiating an attribute • Pros and Cons of descriptors • Data descriptor versus non-data descriptors • How to do Read-Only Descriptors and Writing _delete() • Attribute access and Descriptors • How to store attributes • Fetching the Name (__set_name__()) • Instance-Level Descriptors • Use a pip install-able library called descriptor_tools

Our Sidebar

You can put any information here you'd like.

  • Latest Posts
  • Announcements
  • Calendars
  • etc