当 Python 更新时,我是否需要更新我的程序?

发布于 2025-01-07 02:06:26 字数 280 浏览 1 评论 0原文

我正在开发我的第一个基于 Python 的程序。我希望它在未来尽可能免维护,我想知道随着 Python 的更新这是否会成为一个问题。我目前使用的是 2.7.2,但是当 3 成为标准时,我的程序会发生什么情况?它是否可能会在安装了 Python 3 的系统上停止工作,并且让用户安装旧版本的 Python 是否不切实际?我认为 2.7.2 不会无限期地维护,并且我不认为较新版本的 Python 会成功运行我的程序。抱歉,如果这看起来像是一个新问题;我习惯于使用编译语言。

不要偏离主题太远,但是在这种情况下使用 Lua 会更好吗?

I'm working on my first Python-based program. I would like it to be as maintenance free in the future as possible and I was wondering if this could be a problem as Python is updated. I'm using 2.7.2 currently, but when 3 becomes standard what could happen to my program? Will it likely stop working on a system installed with Python 3 and will it be impractical to have the user install an older version of Python? I assume 2.7.2 won't be maintained indefinitely, and I wouldn't think newer versions of Python would run my program successfully. Sorry if this seems like a newb question; I'm used to working with compiled languages.

Not to stray too far off topic, but would it be better to use Lua in this case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千仐 2025-01-14 02:06:27

它会停止工作吗——这取决于程序的运行方式。如果系统安装了两个版本并且您要求针对 Python 2 运行,那么它将继续工作。如果您没有明确要求针对某个版本运行,并且该版本不存在,那么它可能会失败。

Lua 在这里没有为您提供解决方案 - 如果您依赖系统安装的 Lua 并且 Lua 将来变得不兼容,那么您就会陷入困境。将您的脚本语言视为动态库 - 如果用户拥有正确的版本,那么他们就可以,如果没有,他们就不行,就像 C/C++ 应用程序一样。

如果您要部署到类 Unix 平台,我预计它们将支持 Python 2 至少 5 年,也许 10 年。

如果您要部署到 Windows 平台,您通常会将相关版本的 Python 打包为你的应用程序。

因此,问题不太可能像您担心的那么严重。

Will it stop working - that depends on how the program is being run. If the system has both versions installed and you ask to run against Python 2, then it'll continue to work. If you don't explicitly ask to run against a certain version, and it's not there, then it'll probably fail.

Lua offers you no solutions here - if you rely on a system-installed Lua and that Lua becomes incompatible in the future, you're stuck. Think of your scripting language as a dynamic library - if the user has the right version, they're ok, and if not, they don't, just like with C/C++ apps.

If you're deploying to Unix-like platforms, I expect they will support Python 2 for at least another 5 years, maybe 10.

If you're deploying to a Windows platform, you usually package up the relevant version of Python as part of your app.

So the problem is unlikely to be as significant as you fear.

橘亓 2025-01-14 02:06:27

Python2 消亡还需要非常非常长的时间。

Python2 代码很可能需要修改才能与 Python3 一起运行(尽管有 2to3 工具可以帮助迁移),但由于所有适用于 python2 的库都需要数年时间才能 py2 消亡 - 所以你现在真的不必关心它。除此之外,我相信只要有足够多的人使用Python2,版本就会保持最新并进行修复。

It will take a very, very long time until Python2 will die.

Python2 code will most likely require modifications to run with Python3 (there's the 2to3 tool to help with migrating though), but with all the libs out there which are for python2 it will take years until py2 dies - so you don't really have to care about it right now. Besides that, I believe as long as enough people are using Python2, a version will be kept up to date with fixes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文