@decorator syntax is sugar, but for what exactly?
xtian
xtian at toysinabag.com
Mon Aug 9 05:38:55 EDT 2004
xtian at toysinabag.com (xtian) wrote in message news:<d111eafa.0408081949.3c28a465 at posting.google.com>...
> [some badly-formatted code]
Oops - sorry about the nasty layout there - another example of why tabs are evil. ;)
This is what I meant:
def property_(f):
return property(*f())
class DecorationTest(object):
def __init__(self):
self._foo = 1
@property_
def foo():
def get(self):
print "get"
return self._foo
def set(self, val):
print "set"
self._foo = val
return get, set
t = DecorationTest()
print t.foo
t.foo = 3
print t.foo
xtian
More information about the Python-list
mailing list