Why My Code Run Wrong ,it Is About '@property'
I used python 2.5, I want to know how can change the next code when the Platform is python2.5 or python2.6 class C(object): def __init__(self): self._x = None @pro
Solution 1:
Python 2.5 does not support the .setter
and .deleter
sub-decorators of property
; they were introduced in Python 2.6.
To work on both releases, you can, instead, code something like:
classC(object):
def__init__(self):
self._x = Nonedef_get_x(self):
"""I'm the 'x' property."""return self._x
def_set_x(self, value):
self._x = value
def_del_x(self):
del self._x
x = property(_get_x, _set_x, _del_x)
Post a Comment for "Why My Code Run Wrong ,it Is About '@property'"