|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
请问一下,为什么同样的代码在pycharm和idle里结果却是不一样的
这是代码:
- class C:
- def __getattribute__(self, item):
- print('getattribute')
- return super().__getattribute__(item)
- def __setattr__(self, key, value):
- print('setattr')
- super().__setattr__(key,value)
- def __delattr__(self, item):
- print('delattr')
- super().__delattr__(item)
- def __getattr__(self, item):
- print('getattr')
复制代码
这是在pycharm的结果
- >>>c=C()
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattr
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattr
- getattribute
复制代码
这是idle的结果
- >>> c=C()
- >>> c.x
- getattribute
- getattr
复制代码 |
|