检查 Python 3.x 版本的代码兼容性。

huangapple go评论60阅读模式
英文:

Check code compatibility for python 3x versions

问题

我正在编写一个Python脚本来绘制我们在物理课程中研究的系统的演变。我们只使用Python 3.6+。我与我的同学分享我的代码,上次我们完成类似任务时,我遇到了一个让人讨厌的问题。我在我的机器上有Python 3.11.4,因为我喜欢拥有最新的Python功能。我意外地使用了一个3.10的功能,导致我的代码在一些朋友的机器上崩溃,他们的Python版本是3.7-3.9。有没有一种方法可以检查我的代码将在哪些Python版本上运行而不必自己安装这些版本?

我想确保代码至少与Python 3.7兼容(因为我不放弃dataclasses)。有没有一个可以告诉我我的代码将在哪些Python版本上运行的库、程序或网站?

另外,我使用Visual Studio Code作为编辑器,所以是否有一个VSCode扩展程序可以检查它(如果可能的话,VSCode会突出显示兼容性错误,这将很好)。当然,我首选一个与编辑器无关的解决方案。

英文:

I am making a Python script to plot the evolution of a system we are studying in a Physics course. We only use Python 3.6+. I share my code with my classmates and the last time we did such a task, I ran into an annoying issue. I have Python 3.11.4 on my machine because I like having the most recent features of Python. I accidentally used a 3.10 feature which made my code crash for some of my friends who had 3.7-3.9. Is there a way to check which versions of Python my code will work on without installing these versions myself?

I want to make sure the code is compatible with Python 3.7 at least (because I don't give up dataclasses). Is there a library, program, or website which can tell me which versions of Python my code will work on?

Alternatively, I am using Visual Studio Code as an editor, so is there a VSCode extension that checks it (it would be nice for VSCode to highlight a compatibility error if it can). Of course, I prefer an editor-independent solution first.

答案1

得分: 1

  • 有没有可以告诉我我的代码适用于哪些Python版本的库、程序或网站?
  • 存在 vermin ,可以检测运行代码所需的最低Python版本。
英文:

> Is there a library, program, or website which can tell me which
> versions of Python my code will work on?

There exist vermin which

> detect the minimum Python versions needed to run code

huangapple
  • 本文由 发表于 2023年6月12日 01:34:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76451698.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定