W
webmaster
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
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