首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
推荐学习书目
›
Learn Python the Hard Way
Python Sites
›
PyPI
- Python Package Index
›
http://diveintopython.org/toc/index.html
›
Pocoo
值得关注的项目
›
PyPy
›
Celery
›
Jinja2
›
Read the Docs
›
gevent
›
pyenv
›
virtualenv
›
Stackless Python
›
Beautiful Soup
›
结巴中文分词
›
Green Unicorn
›
Sentry
›
Shovel
›
Pyflakes
›
pytest
Python 编程
›
pep8 Checker
Styles
›
PEP 8
›
Google Python Style Guide
›
Code Style from The Hitchhiker's Guide
V2EX
›
Python
关于在__getattribute__调用 getattr()的问题
sudo987
·
2016-07-05 23:16:33 +08:00
· 2295 次点击
这是一个创建于 3006 天前的主题,其中的信息可能已经有所发展或是发生改变。
刚才发了一篇帖子
http://v2ex.com/t/290512#reply1
,后来想想还是不对, getattr(self.__obj, attr)相当于 self.__obj.attr ,调用的是 self.__obj 本身的__getattribute__方法,跟外层__getattribute__没有关系,不解为什么会出现死循环。
getattr
调用
帖子
刚才
2 条回复
•
2016-07-06 13:47:18 +08:00
1
perpyy
2016-07-06 00:05:53 +08:00
self.__obj 要不要调外层__getattribute__
2
kaneg
2016-07-06 13:47:18 +08:00
覆盖__getattr__而不是__getattribute__。
代码详情见原帖的回复。
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
2493 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 25ms ·
UTC 05:43
·
PVG 13:43
·
LAX 22:43
·
JFK 01:43
Developed with
CodeLauncher
♥ Do have faith in what you're doing.