We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.


property([fget[, fset[, fdel[, doc]]]]) => descriptor

Returns a property descriptor 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 deleting, an attribute. Typical use is to define a managed attribute x:

class C(object):
    def __init__(self): self.__x = None
    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.")

o = C()
value = o.x # calls getx
o.x = value # calls setx
del o.x # calls delx

New in version 2.2.