Sick problem with Python properties

webmaster at t-dose.de webmaster at t-dose.de
Thu Aug 7 13:02:56 CEST 2003


See the following code. I wonder why in this case neither
setp() nor getp() is called !?


yetix@/home/ajung(1)% cat test.py
class A:

    def __init__(self):
        self._p=None

    def setp(self, p):
        print 'set'
        self._p = p*p

    def getp(self):
        print 'get'
        return self._p

    pp = property(getp, setp)


inst=A()
inst.p = 9
print inst.p

yetix@/home/ajung(2)% python2.3 test.py
9

Cheers,
-aj







More information about the Python-list mailing list