- A property in Python in an attribute which has an getter, setter and deleter method (Not necessary to implement all three methods)
- They are used to encapsulate the attributes in the class. It is the pythonic way to declare getters and setters
- A property can be created using the
@property
decorator (recommended) orproperty()
method
__get__()
,__set__()
or__delete__()
(Descriptor Protocol) is called as descriptorThere are two types of descriptors:
- Data Descriptors : Objects that implement
__set__()
and__delete__()
- Non Data Descriptors : Objects that implement
__get__()