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

问一个 Python 3.4 closure 的问题

  •  
  •   Ultratude · Jun 20, 2015 · 4703 views
    This topic created in 3983 days ago, the information mentioned may be changed or developed.
    有一项目 Python 2.7 的 code 类似这样,现在想要兼容 3.4。

    Python 3.4 下会报错,搜了很久没有很好的答案。
    求教,谢谢。
    7 replies    2015-06-20 23:44:35 +08:00
    Ultratude
        1
    Ultratude  
    OP
       Jun 20, 2015
    主帖里贴两条 gist,会显示同一条两遍,貌似是 bug。
    所以错误贴在这里。
    https://gist.github.com/ultratude/29bb8021a3ac4f1153da
    Valyrian
        2
    Valyrian  
       Jun 20, 2015   ❤️ 1
    这。。感觉是应该能正常运行的code
    Ultratude
        3
    Ultratude  
    OP
       Jun 20, 2015
    @Valyrian 是啊,我也觉得没问题,十分蛋疼。
    kcworms
        4
    kcworms  
       Jun 20, 2015   ❤️ 1
    原因在 https://www.python.org/dev/peps/pep-3110/

    可以尝试:把异常实例里要用的内容拷贝一下,之后再也不要引用了
    killpanda
        5
    killpanda  
       Jun 20, 2015   ❤️ 1
    Ultratude
        6
    Ultratude  
    OP
       Jun 20, 2015
    @killpanda
    @kcworms
    非常感谢!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2824 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 15:29 · PVG 23:29 · LAX 08:29 · JFK 11:29
    ♥ Do have faith in what you're doing.