I am trying to use new style property declaration:
class C(object): def __init__(self): self._x = 0 @property def x(self): print 'getting' return self._x @x.setter def set_x(self, value): print 'setting' self._x = value if __name__ == '__main__': c = C() print cx cx = 10 print cx
and see the following in the console:
pydev debugger: starting getting 0 File "\test.py", line 55, in <module> cx = 10 AttributeError: can't set attribute
what am I doing wrong? PS: The old style declaration works great.
python
Maxim Popravko Nov 15 '10 at 10:27 2010-11-15 10:27
source share