我应该使用哪个版本的 Python 来开发 Web 应用程序?
目前我的系统上安装了 Python 3.1.1,服务器上安装了相同版本,WSGI 3.0 在 Apache 2.2 上运行。
我想继续使用Python 3.1,但我发现很多库/框架还不支持它,即Django、Pylons、MySQLdb等。
我还检查了我在朋友服务器上的帐户,它是运行Python 2.3.4...
我想编写一种博客/论坛类型的应用程序,我可以将其扩展为CMS,并最终为其编写相关的桌面应用程序,作为一种长期的宠物项目。
我想使用最新版本的 Python,以获得最佳安全性和与未来桌面应用程序的最高一致性,同时仍然保持良好的可移植性,并支持我将使用的大多数框架和库。
但我不知道该选择哪一个。看起来 2.4 具有最大的可移植性,但它有点旧了,我不想最终使用一堆无法编译的 2.4 后功能,并且必须用更混乱的代码重新编写补偿它。 2.6 会更好,但似乎很多库仍在移植到该版本,而 3.1 是最好的,因为它消除了该语言中的许多缺陷。
我想强调的一件事是,如果我选择旧版本的 Python,如果知道我会错过什么,那就太好了。例如,如果我需要我的应用程序在我朋友的服务器上的旧 Python 2.3.4 帐户上运行,我将缺少新版本中存在的哪些库/功能?我肯定会遇到哪些问题会让我希望使用Python 2.6或3.1?通过 __future__ 导入可以使用哪些功能?
那么,最好的方向是什么?我应该只使用 2.6 并处理任何问题吗?我是否应该选择 2.4 以最大限度地提高将其分发到共享托管环境的能力?或者我应该跳到 3.1 并拥有一个稍微残缺的应用程序,直到像 MySQLdb 这样的库迎头赶上?
Currently I have Python 3.1.1 installed on my system, same version on my server with WSGI 3.0 running on Apache 2.2.
I want to keep using Python 3.1, but I'm finding that lots of libraries/frameworks don't support it yet, namely Django, Pylons, MySQLdb, etc.
I also checked an account I have on a friend's server, and it is running Python 2.3.4...
I want to write a sort of blog/forum type application that I can expand into a CMS, and eventually write related desktop applications for, as sort of a long-term pet project.
I'd like to use the newest version of Python possible for best security and highest consistency with the desktop-applications-to-be, while still maintaining a good level of portability, and supporting most of the frameworks and libraries I will use.
But I'm lost on which one I should pick. It seems like 2.4 would have the greatest amount of portability but it's sort of old, and I don't want to wind up using a bunch of post-2.4 features that won't compile, and having to re-write with messier code to compensate for it. 2.6 would be better, but it seems like lots of libraries are still porting over to that, and 3.1 would be the best since it eliminates a lot of cruft from the language.
One thing I'd like to highlight is that it'd be nice to know what I will be missing if I choose an older version of Python. For example, if I were to need my application to run on my old Python 2.3.4 account on my friend's server, what libraries/features would I be lacking that exist in newer versions? What problems would I surely run into that would make me wish I was using Python 2.6 or 3.1? Which of these features would be available via __future__
imports?
So, what would be the best direction to go? Should I just use 2.6 and deal with any issues? Should I go for 2.4 to maximize my ability to possibly distribute it to shared hosting environments? Or should I just jump into 3.1 and have a slightly-crippled application until libraries like MySQLdb catch up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
目前,Python 3 尚未在生产中广泛部署。取决于你用Python做什么。如果只是一次性脚本,那么无论哪种方式都可以,如果想法是使用第三方模块、C 模块和/或轻松部署,那么就选择任何 2.4+ 版本。许多项目都努力保持 2.3 的兼容性,但使用 2.4-2.6 应该不会有任何问题,因为语言的变化很小。如果可以的话,请使用 2.6,因为它最接近 Python 3,因为它有一些向后移植的功能。
Python 3 的问题是第 22 条军规:
使用 2.4-2.6 中的任何一个都不应该有任何问题,请给 3 一些时间。
使用Python 2.6
For now, Python 3 is not widely deployed in production. Depends on what you use Python for. If it's just for one off scripts, it will be ok either way, if the idea is to use third party modules, C modules and or deploy painlessly, then settle for any of the 2.4+ versions. Many projects strive to keep 2.3 compativility, but you shouldn't have any problems to use 2.4-2.6, as the changes in the language are minor. If you can, use 2.6, as it's the closest to Python 3, as it has some features backported to it.
The problem with Python 3 is a Catch 22:
You should not have any problems using any of the 2.4-2.6, give 3, some time.
Use Python 2.6
如果您不确定,请从 Python 2.5 开始。
看看 Google App Engine(基于 Django)。它使用 Python 2.5 并且是免费的。
但是,您将无法调用 scipy(例如)或任何内部带有“C”的库。
使用Python2.5,您将获得最大程度的可移植性。而且,python3k并没有真正在工业界使用。
Begin with Python 2.5 if you're not sure.
Have a look at Google App Engine (based on Django). It's using Python 2.5 and it's free.
However, you will not be able to call scipy (for example) or any libraries with "C" inside.
You will have the greatest amount of portability with Python2.5. Moreover, python3k is not really used in the industry.
“2.6 会更好,但似乎很多库仍在移植到该版本”
什么?您需要哪些库“仍在移植到该库”?
“3.1 是最好的”“但我发现很多库/框架不支持”
正确。你在问题中已经说过两次了。这非常清楚。
“我应该只使用 2.6 并处理任何问题”
什么问题?您有什么具体的担忧吗?
看起来效果真的非常好。您具体关心什么?
"2.6 would be better, but it seems like lots of libraries are still porting over to that"
What? What libraries -- that you need -- are "still porting over to that"?
"3.1 would be the best" "but I'm finding that lots of libraries/frameworks don't support"
Correct. You've stated that twice in the question. That's very clear.
"Should I just use 2.6 and deal with any issues"
What issues? Do you have any specific concerns?
It seems to work really, really well. What are your specific concerns?
对于 Intranet Web 应用程序,我必须安装 python 2.5(由于 wiki、错误跟踪器和 httpd WSGI 兼容性的组合)。
对于自定义 Web 应用程序,我在 python 3.2 上进行了标准化。
因此我同时安装了两者。我为 3.2 编写代码,并根据需要使特定库符合规范。然而,我不想修改的大型软件包使用它们自己的 2.5。
目前,3.2 和第 3 方软件包之间的兼容性仍然是一个问题,而且缺乏适当的 python 配方也是一个问题。
总之:安装两个版本。
For intranet web apps I had to install python 2.5 (due to combination of wiki, bug tracker, and httpd WSGI compatibility).
For custom web apps I standardized on python 3.2.
Thus I have both installed simultaneously. I write for 3.2 and bring specific libraries up to spec as needed. However large packages which I don't want to modify use their own 2.5.
Compatibility between 3.2 and 3rd party packages is still an issue at this time, and so is the lack of proper python recipes.
In summary: Install two versions.