class Ball:
def __init__(self, attr):
if attr <= 0:
raise ValueError('必須是正數')
self.attr = attr
@property
def getFunc(self):
return self.attr
@getFunc.setter
def propertyName(self, radius):
self.attr = attr
@getFunc.deleter
def propertyName(self):
del self.attr
b = Ball(1)
print(b.propertyName)
#
沒有留言:
張貼留言