首页
注册
登录
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
问一个 Python 3.4 closure 的问题
Ultratude
·
2015-06-20 14:15:02 +08:00
· 3932 次点击
这是一个创建于 3548 天前的主题,其中的信息可能已经有所发展或是发生改变。
有一项目 Python 2.7 的 code 类似这样,现在想要兼容 3.4。
https://gist.github.com/ultratude/c43a89d1ce03220d6a0c
显示 Gist 代码
Python 3.4 下会报错,搜了很久没有很好的答案。
求教,谢谢。
Python
Closure
求教
7 条回复
•
2015-06-20 23:44:35 +08:00
1
Ultratude
OP
2015-06-20 14:20:01 +08:00
主帖里贴两条 gist,会显示同一条两遍,貌似是 bug。
所以错误贴在这里。
https://gist.github.com/ultratude/29bb8021a3ac4f1153da
2
Valyrian
2015-06-20 15:01:15 +08:00
1
这。。感觉是应该能正常运行的code
3
Ultratude
OP
2015-06-20 15:14:00 +08:00
@
Valyrian
是啊,我也觉得没问题,十分蛋疼。
4
kcworms
2015-06-20 15:16:03 +08:00
1
原因在
https://www.python.org/dev/peps/pep-3110/
可以尝试:把异常实例里要用的内容拷贝一下,之后再也不要引用了
5
killpanda
2015-06-20 15:17:47 +08:00
1
可以这样吧:
https://gist.github.com/killpanda/3539b9e02270050469c7
6
Ultratude
OP
2015-06-20 15:42:56 +08:00
@
killpanda
@
kcworms
非常感谢!
7
isaaczeng
2015-06-20 23:44:35 +08:00
https://gist.github.com/gfZeng/103ae58a8301a64e27b8
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
1178 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms ·
UTC 18:17
·
PVG 02:17
·
LAX 10:17
·
JFK 13:17
Developed with
CodeLauncher
♥ Do have faith in what you're doing.