class TestPropertyDecorator(object): def init(self, value): self.x = value
代码语言:javascript复制@property
def x(self):
return self._x
@x.setter
def x(self, value):
if not (type(value) == int and 0 < value < 32):
raise ValueError("TestProperty.x "
"must be an integer between 0 and 32")
self._x = value