deleter — Python Reference (The Right Way) 0.1 documentation
文章推薦指數: 80 %
A property object has getter, setter, and deleter methods usable as decorators that create a copy of the property with the corresponding accessor function ... PythonReference(TheRightWay) latest Introduction Definitions CodingGuidelines FundamentalDataTypes Built-InFunctions ComprehensionsandGeneratorExpression ContainerDataAccess Operators Statements OtherObjects DoubleUnderscoreMethodsandVariables Exceptions Constants Boilerplate GlimpseofthePSL Resources Licence PythonReference(TheRightWay) Docs» deleter EditonGitHub deleter¶ Description¶ Overridesattributeaccessmechanism. Syntax¶ property.getter(method) method Amethodtodecorate. ReturnValue¶ None TimeComplexity¶ #TODO Remarks¶ Apropertyobjecthasgetter,setter,anddeletermethodsusableasdecoratorsthatcreateacopyofthepropertywiththecorrespondingaccessorfunctionsettothedecoratedfunction.Thisisbestexplainedwithanexample: classC(object): def__init__(self): self._x=None @property defx(self): """I'mthe'x'property.""" returnself._x @x.setter defx(self,value): self._x=value @x.deleter defx(self): delself._x Thiscodeisexactlyequivalenttothefirstexample.Besuretogivetheadditionalfunctionsthesamenameastheoriginalproperty(xinthiscase.) Thereturnedpropertyalsohastheattributesfget,fset,andfdelcorrespondingtotheconstructorarguments. Example¶ >>>foo 3.6055512754639896 ReadtheDocs v:latest Versions latest Downloads pdf htmlzip epub OnReadtheDocs ProjectHome Builds FreedocumenthostingprovidedbyReadtheDocs.
延伸文章資訊
- 1Python property() - Programiz
a deleter method del_name() to delete the name of the person. Now, we set a new property attribut...
- 2deleter — Python Reference (The Right Way) 0.1 documentation
A property object has getter, setter, and deleter methods usable as decorators that create a copy...
- 3deleter decorator using Property in Python - Stack Overflow
I'm playing around with property in Python and I was wondering how this @propertyName.deleter dec...
- 4The @property Decorator in Python: Its Use Cases ...
How you can use @property to define getters, setters, and deleters. 1️⃣ Advantages of Properties ...
- 5Python Property Decorator - TutorialsTeacher
Use the @property-name.deleter decorator to define the method that deletes a property, as shown b...