Questions tagged «new-style-class»


4
为什么Python中的@ foo.setter对我不起作用?
因此,我正在使用Python 2.6中的装饰器,并且在使它们工作时遇到了一些麻烦。这是我的课程文件: class testDec: @property def x(self): print 'called getter' return self._x @x.setter def x(self, value): print 'called setter' self._x = value 我认为这意味着将其视为x属性,但是在get和set上调用这些函数。因此,我启动了IDLE并检查了它: >>> from testDec import testDec from testDec import testDec >>> t = testDec() t = testDec() >>> t.x t.x called getter Traceback (most recent call last): File …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.