|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
做练习时参照做了一个测试,代码如下:
class C:
def __init__(self,x=10):
self.x=x
def getxy(self):
return self.x
def setxy(self,value):
self.x=value
def delxy(self):
del self.x
x=property(getxy,setxy,delxy)
实例化c1=C()时会报错:
>>> c1=C()
Traceback (most recent call last):
File "<pyshell#55>", line 1, in <module>
c1=C()
File "C:/Users/MOMO/Desktop/1.py", line 3, in __init__
self.x=x
File "C:/Users/MOMO/Desktop/1.py", line 7, in setxy
self.x=value
File "C:/Users/MOMO/Desktop/1.py", line 7, in setxy
self.x=value
File "C:/Users/MOMO/Desktop/1.py", line 7, in setxy
self.x=value
[Previous line repeated 1020 more times]
RecursionError: maximum recursion depth exceeded
>>>
把参数x换成其他字符就没问题,用x就不行。
百思不得骑姐。
求各位大侠指点 |
|