PEP318: property as decoration
Sean Ross
sross at connectmail.carleton.ca
Tue Jun 10 20:29:10 EDT 2003
There was an indentation error with the propertythunk code:
def myproperty(thunk):
fget, fset, fdel, fdoc = thunk()
return property(fget, fset, fdel, fdoc)
def propertythunk():
def fget(self):
return self._foo
def fset(self, value):
self._foo = value
def fdel(self):
del self._foo
fdoc = "foo"
return fget, fset, fdel, fdoc
class MyClass(object):
def __init__(self):
self._foo = "foo"
foo = myproperty(propertythunk) # the error was here
x = MyClass()
print x.foo # "foo"
x.foo = "changed"
print x.foo # "changed"
More information about the Python-list
mailing list