Monday, 12 October 2015

DEscriptORS

Python descriptors are a way to create managed attributes.

Python descriptor protocol is simply a way to specify what happens when an attribute is referenced on a model. It allows a programmer to easily and efficiently manage attribute access:
  • set
  • get
  • delete
Managed attributes are used to protect an attribute from changes or to automatically update the values of a dependant attribute.
We can create a descriptor in a number of ways like:
  • using class methods
  • using property type
  • using property decorators

No comments:

Post a Comment