Python 2.6 到 2.5 备忘单
我已经编写了针对 Python 2.6.5 的代码,但现在我需要在只有 2.5.4 的集群上运行它,而这在我编写代码时还没有出现。将代码向后移植到 2.5 应该不会太难,但我想知道是否有备忘单或自动化工具可以帮助我完成此任务。对于某些事情,例如 with
语句,正确的 __future__
导入可以解决问题,但对于其他一些事情则不然。
I've written my code to target Python 2.6.5, but I now need to run it on a cluster that only has 2.5.4, something that wasn't on the horizon when I wrote the code. Backporting the code to 2.5 shouldn't be too hard, but I was wondering if there was either a cheat-sheet or an automated tool that would help me with this. For some things, like the with
statement, the right __future__
imports will do the trick, but not for some other things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尝试过 pyqver 吗?它会告诉你你的代码所需的最低Python版本
我希望它有帮助
Have you tried pyqver? It will tell you which is the minimum version of Python required by your code
I hope it helps
您是否阅读过 Python 2.6 的新增功能文档?它描述了 2.5->2.6 方向,但你应该能够从中找出相反的方向。
据我所知,2.6到2.5还没有自动化工具。我所知道的唯一工具是用于转到 Python 3 的 2to3 应用程序。
Have you read the What's New in Python 2.6 document? It describes the 2.5->2.6 direction, but you should be able to figure out the reverse from it.
As far as I know, there are no automated tools for 2.6 to 2.5. The only tool I know of is the 2to3 app for going to Python 3.