Python descriptors

Resources

What are the descriptors?

Descriptors are Python objects that implement a method of the descriptor protocol, which gives you the ability to create objects that have special behavior when they’re accessed as attributes of other objects.

Examples:

  • We can use @property decorator, used to make pre-build validation before saving.
  • staticmethod, classmethod are also descriptors
  • functions also use get, set, delete dunder methods. And get returns the bound version of the method

Another example:

SuperMade with Super