What is a Python descriptor and what three methods define the descriptor protocol?

Python Developer Hard

Python Developer — Hard

What is a Python descriptor and what three methods define the descriptor protocol?

Key points

  • Descriptors define attribute access behavior in Python classes
  • The descriptor protocol includes __get__, __set__, and __delete__ methods
  • Data descriptors implement __set__/__delete__; non-data descriptors only implement __get__
  • Descriptors are used to customize attribute access behavior in Python

Ready to go further?

Related questions