mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
116 lines
4.3 KiB
Markdown
116 lines
4.3 KiB
Markdown
[#]: 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)
|
||
[#]: translator: (geekpi)
|
||
[#]: reviewer: (wxy)
|
||
[#]: publisher: (wxy)
|
||
[#]: url: (https://linux.cn/article-13536-1.html)
|
||
|
||
Fedora Linux 中的 Python 3.10 测试版
|
||
======
|
||
|
||
![][1]
|
||
|
||
Python 开发者已经发布了 Python 3.10.0 的三个测试版本。现在,你可以在 Fedora Linux 中试用最新的版本尽早用 3.10 测试你的 Python 代码,为 10 月份的 3.10.0 最终版本做好准备。
|
||
|
||
### 在 Fedora Linux 上安装 Python 3.10
|
||
|
||
如果你运行 Fedora Linux,你可以用 `dnf` 从官方仓库安装 Python 3.10:
|
||
|
||
```
|
||
$ sudo dnf install python3.10
|
||
```
|
||
|
||
你可能需要启用 `updates-testing` 仓库来获得最新的预发布版本:
|
||
|
||
```
|
||
$ sudo dnf install --enablerepo=updates-testing python3.10
|
||
```
|
||
|
||
随着更多的测试版和候选版 [发布][2],Fedora 包将得到更新。不需要编译你自己的 Python 开发版本,只要安装它就可以获得最新。从第一个测试版开始,Python 开发者不会再增加新的功能了。你已经可以享受所有的新东西了。
|
||
|
||
### 用 Python 3.10 测试你的项目
|
||
|
||
运行 `python3.10` 命令来使用 Python 3.10,或者用 [内置的 venv 模块 tox][3] 或用 [pipenv][4] 和 [poetry][5] 创建虚拟环境。下面是一个使用 `tox` 的例子:
|
||
|
||
```
|
||
$ 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 :)
|
||
```
|
||
|
||
如果你在 Fedora Linux 上发现了 Python 3.10 的问题,请 [在 Fedora 的 bugzilla 上提交 bug 报告][6] 或在 [Python 的问题追踪][7] 上提交。如果你不确定这是否是 Python 的问题,你可以 [通过电子邮件或 IRC 直接联系 Fedora 的 Python 维护者][8] 。
|
||
|
||
### Python 3.10 中的新内容
|
||
|
||
参见 [Python 3.10 的全部新闻列表][9]。例如,你可以尝试一下 [结构模式匹配][10]:
|
||
|
||
```
|
||
$ 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
|
||
```
|
||
|
||
敬请期待 [Fedora Linux 35 中的 python3 —— Python 3.10][11]!
|
||
|
||
--------------------------------------------------------------------------------
|
||
|
||
via: https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/
|
||
|
||
作者:[Miro Hrončok][a]
|
||
选题:[lujun9972][b]
|
||
译者:[geekpi](https://github.com/geekpi)
|
||
校对:[wxy](https://github.com/wxy)
|
||
|
||
本文由 [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
|