Python Descriptor Classes: Hook into Attribute Access
Python allows us to execute code when an attribute of our class gets accessed, set, or removed through Descriptor Classes. A descriptor class is just a simple class that defines either __get__
, __set__
or __delete__
methods. For example: