2021-06-24 05:03:10 +08:00
|
|
|
|
[#]: subject: (Python 3.10 beta in Fedora Linux)
|
|
|
|
|
[#]: via: (https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/)
|
|
|
|
|
[#]: author: (Miro Hrončok https://fedoramagazine.org/author/churchyard/)
|
|
|
|
|
[#]: collector: (lujun9972)
|
2021-06-25 08:56:33 +08:00
|
|
|
|
[#]: translator: (geekpi)
|
2021-06-24 05:03:10 +08:00
|
|
|
|
[#]: reviewer: ( )
|
|
|
|
|
[#]: publisher: ( )
|
|
|
|
|
[#]: url: ( )
|
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
Fedora Linux 中的 Python 3.10 测试版
|
2021-06-24 05:03:10 +08:00
|
|
|
|
======
|
|
|
|
|
|
|
|
|
|
![][1]
|
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
Python 开发者已经发布了 Python 3.10.0 的三个测试版本。今天,你可以在 Fedora Linux 中试用最新的版本 尽早用 3.10 测试你的 Python 代码,为 10 月份的 3.10.0 最终版本做好准备。
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
### 在 Fedora Linux 上安装 Python 3.10
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
如果你运行 Fedora Linux,你可以用 _dnf_ 从官方仓库安装 Python 3.10:
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ sudo dnf install python3.10
|
|
|
|
|
```
|
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
你可能需要启用 _updates-testing_ 仓库来获得最新的预发布版本:
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ sudo dnf install --enablerepo=updates-testing python3.10
|
|
|
|
|
```
|
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
随着更多的测试版和候选版[将被发布][2],Fedora 包将得到更新。不需要编译你自己的 Python 开发版本,只要安装它就可以获得最新。从第一个测试版开始,Python 开发者将不增加新的功能。你已经可以享受所有的新东西了。
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
### 用 Python 3.10 测试你的项目
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
运行 _python3.10_ 命令来使用 Python 3.10,或者用[内置的 _venv_ 模块 tox][3] 或用 [pipenv][4] 和 [poetry][5] 创建虚拟环境。下面是一个使用 _tox_ 的例子:
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ git clone https://github.com/benjaminp/six.git
|
|
|
|
|
Cloning into 'six'...
|
|
|
|
|
$ cd six/
|
|
|
|
|
$ tox -e py310
|
|
|
|
|
py310 run-test: commands[0] | python -m pytest -rfsxX
|
|
|
|
|
================== test session starts ===================
|
|
|
|
|
platform linux -- Python 3.10.0b3, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
|
|
|
|
|
collected 200 items
|
|
|
|
|
|
|
|
|
|
test_six.py ...................................... [ 19%]
|
|
|
|
|
.................................................. [ 44%]
|
|
|
|
|
.................................................. [ 69%]
|
|
|
|
|
.................................................. [ 94%]
|
|
|
|
|
............ [100%]
|
|
|
|
|
|
|
|
|
|
================== 200 passed in 0.43s ===================
|
|
|
|
|
________________________ summary _________________________
|
|
|
|
|
py310: commands succeeded
|
|
|
|
|
congratulations :)
|
|
|
|
|
```
|
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
如果您在 Fedora Linux 上发现了 Python 3.10 的问题,请[在 Fedora 的 bugzilla 上提交 bug 报告][6]或在 [Python 的问题追踪][7]上提交。如果你不确定这是否是 Python 的问题,你可以[通过电子邮件或 IRC 直接联系 Fedora 的 Python 维护者][8] 。
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
### Python 3.10 中的新内容
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
参见 [Python 3.10 的全部新闻列表][9]。例如,你可以尝试一下[结构模式匹配][10]:
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ python3.10
|
|
|
|
|
Python 3.10.0b3 (default, Jun 17 2021, 00:00:00)
|
|
|
|
|
[GCC 10.3.1 20210422 (Red Hat 10.3.1-1)] on linux
|
|
|
|
|
Type "help", "copyright", "credits" or "license" for more information.
|
|
|
|
|
>>> point = (3, 10)
|
|
|
|
|
>>> match point:
|
|
|
|
|
... case (0, 0):
|
|
|
|
|
... print("Origin")
|
|
|
|
|
... case (0, y):
|
|
|
|
|
... print(f"Y={y}")
|
|
|
|
|
... case (x, 0):
|
|
|
|
|
... print(f"X={x}")
|
|
|
|
|
... case (x, y):
|
|
|
|
|
... print(f"X={x}, Y={y}")
|
|
|
|
|
... case _:
|
|
|
|
|
... raise ValueError("Not a point")
|
|
|
|
|
...
|
|
|
|
|
X=3, Y=10
|
|
|
|
|
>>> x
|
|
|
|
|
3
|
|
|
|
|
>>> y
|
|
|
|
|
10
|
|
|
|
|
```
|
|
|
|
|
|
2021-06-29 08:36:39 +08:00
|
|
|
|
请继续关注 [Fedora Linux 35 中将采用 Python 3.10 作为 _python3_][11]!
|
2021-06-24 05:03:10 +08:00
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
via: https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/
|
|
|
|
|
|
|
|
|
|
作者:[Miro Hrončok][a]
|
|
|
|
|
选题:[lujun9972][b]
|
2021-06-29 08:36:39 +08:00
|
|
|
|
译者:[geekpi](https://github.com/geekpi)
|
2021-06-24 05:03:10 +08:00
|
|
|
|
校对:[校对者ID](https://github.com/校对者ID)
|
|
|
|
|
|
|
|
|
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
|
|
|
|
|
|
|
|
[a]: https://fedoramagazine.org/author/churchyard/
|
|
|
|
|
[b]: https://github.com/lujun9972
|
|
|
|
|
[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/python310-beta-816x345.jpg
|
|
|
|
|
[2]: https://www.python.org/dev/peps/pep-0619/
|
|
|
|
|
[3]: https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html
|
|
|
|
|
[4]: https://fedoramagazine.org/install-pipenv-fedora/
|
|
|
|
|
[5]: https://python-poetry.org/
|
|
|
|
|
[6]: https://bugzilla.redhat.com/buglist.cgi?component=python3.10&product=Fedora
|
|
|
|
|
[7]: https://bugs.python.org/
|
|
|
|
|
[8]: https://fedoraproject.org/wiki/SIGs/Python#Communicate
|
|
|
|
|
[9]: https://docs.python.org/3.10/whatsnew/3.10.html
|
|
|
|
|
[10]: https://www.python.org/dev/peps/pep-0634/
|
|
|
|
|
[11]: https://fedoraproject.org/wiki/Changes/Python3.10
|