@decorator syntax is sugar, but for what exactly?

xtian xtian at toysinabag.com
Mon Aug 9 11:38:55 CEST 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
    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


More information about the Python-list mailing list