Python 2.2 properties
Steven D. Arnold
stevena at neosynapse.net
Tue Jan 15 06:19:42 EST 2002
Am I misunderstanding how properties work? It seems that given the
code below, i.a ought to equal 5 no matter what. What am I doing
wrong?
>>> sys.version
'2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)]'
>>> class foo:
... def __init__(self):
... self.a = 5
... def seta(self, value):
... self._a = 5
... def geta(self):
... return self._a
... a = property(geta, seta)
...
>>> i = foo()
>>> i.a
5
>>> i.a = 6
>>> i.a
6
--------------------------------------------------------------
Steven D. Arnold stevena at neosynapse.net Managing Partner
More information about the Python-list
mailing list