[Tutor] Documentation on properties

Tony Cappellini tony at tcapp.com
Wed Sep 29 03:15:09 CEST 2004



The following is straight out of the python documentation

 property( [fget[, fset[, fdel[, doc]]]])

Return a property attribute for new-style classes (classes that derive
from object).
fget is a function for getting an attribute value, likewise fset is a
function for setting, and fdel a function for del'ing, an attribute.
Typical use is to define a managed attribute x:


class C(object):
    def getx(self): return self.__x
    def setx(self, value): self.__x = value
    def delx(self): del self.__x
    x = property(getx, setx, delx, "I'm the 'x' property.")





Why is x not referred to as self.x in the x=property(getx, setx, delx, "")
 line ?



More information about the Tutor mailing list