推荐学习书目
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
sudo987
V2EX  ›  Python

关于在__getattribute__调用 getattr()的问题

  •  
  •   sudo987 · Jul 5, 2016 · 2979 views
    This topic created in 3620 days ago, the information mentioned may be changed or developed.
    刚才发了一篇帖子 http://v2ex.com/t/290512#reply1 ,后来想想还是不对, getattr(self.__obj, attr)相当于 self.__obj.attr ,调用的是 self.__obj 本身的__getattribute__方法,跟外层__getattribute__没有关系,不解为什么会出现死循环。
    2 replies    2016-07-06 13:47:18 +08:00
    perpyy
        1
    perpyy  
       Jul 6, 2016
    self.__obj 要不要调外层__getattribute__
    kaneg
        2
    kaneg  
       Jul 6, 2016
    覆盖__getattr__而不是__getattribute__。
    代码详情见原帖的回复。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   914 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 21:05 · PVG 05:05 · LAX 14:05 · JFK 17:05
    ♥ Do have faith in what you're doing.