Python 开发人员已经发布了 Python 3.8.0 的第一个 alpha 版本,您已经可以在 Fedora! 一旦最终的 3.8.0 在 10 月发布,请尽早使用 3.8 测试您的 Python 代码,以避免出现意外。
安装 Python 3.8 Fedora
如果你有 Fedora 29 或更高版本,您可以使用 dnf 从官方软件存储库安装 Python 3.8:
$ sudo dnf install python38
随着更多的 alpha、beta 和发布候选版本 Python 3.8 将发布, 这 Fedora 包将收到更新。 无需编译您自己的 Python 开发版本,只需安装并更新即可。 新功能将添加到第一个 beta.
使用 Python 3.8 测试您的项目
运行 python3.8 命令以使用 Python 3.8 或使用 内置 venv 模块,毒物 或使用 pipenv。 为了 example:
$ git clone https://github.com/benjaminp/six.git
Cloning into 'six'...
$ cd six/
$ tox -e py38
py38 runtests: commands[0] | python -m pytest -rfsxX
================== test session starts ===================
platform linux -- Python 3.8.0a1, pytest-4.2.1, py-1.7.0, pluggy-0.8.1
collected 195 items
test_six.py ...................................... [ 19%]
.................................................. [ 45%]
.................................................. [ 70%]
..............................................s... [ 96%]
....... [100%]
========= 194 passed, 1 skipped in 0.25 seconds ==========
________________________ summary _________________________
py38: commands succeeded
congratulations :)
Python 3.8 中的新功能
到目前为止,只发布了第一个 alpha,所以 更多功能将出现. 但是,您已经可以尝试 新海象算子:
$ python3.8
Python 3.8.0a1 (default, Feb 7 2019, 08:07:33)
[GCC 8.2.1 20181215 (Red Hat 8.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> while not (answer := input('Say something: ')):
... print("I don't like empty answers, try again...")
...
Say something:
I don't like empty answers, try again...
Say something: Fedora
>>>
敬请期待 Python 3.8 作为 python3 在 Fedora 31!