- First, a section of official document pressure yajing.
-
-
-
-
Property (fget=none, fset=none, fdel=none, doc=none)
-
Return a property attribute.
Fget is a function for getting an attribute value, likewise fset are a function for setting, and fdel a function for del ' ing, an attribute. Typical use are to define a managed attribute x:
ClassC:Def__init__(Self):Self._x=NoneDefGetx(Self):ReturnSelf._x def setx (self value): self. _x = value def delx ( selfdel self. _x x = property (getxsetxdelx "I ' m the ' x ' property." ) /span>
If then C was an instance of C, c.x would invoke the getter, c.x = value would invoke the setter and del c.x the deleter.
-
The use of the property is to set an attribute value for your class. The first parameter sets the method that gets the value of the property, the second parameter sets the method for setting the property value, the third parameter sets the method to delete the property value, and the fourth parameter is the document. C.x invokes the method of the first argument, c.x = value calls the second method, and Del c.x calls the third method. Such
What do you do with the property in Python?