Merge pull request #22304 from lujun9972/add-MjAyMTA2MjMgUHl0aG9uIDMuMTAgYmV0YSBpbiBGZWRvcmEgTGludXgubWQK

自动选题[tech]: 20210623 Python 3.10 beta in Fedora Linux
This commit is contained in:
Xingyu.Wang 2021-06-24 10:29:19 +08:00 committed by GitHub
commit e7d6bc74da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,115 @@
[#]: 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: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Python 3.10 beta in Fedora Linux
======
![][1]
The Python developers have already released three beta versions of Python 3.10.0. You can try the latest one in Fedora Linux today! Test your Python code with 3.10 early to be ready for the final 3.10.0 release in October.
### Install Python 3.10 on Fedora Linux
If you run Fedora Linux, you can install Python 3.10 from the official software repository with _dnf_:
```
$ sudo dnf install python3.10
```
You might need to enable the _updates-testing_ repository to get the very latest pre-release:
```
$ sudo dnf install --enablerepo=updates-testing python3.10
```
As more betas and release candidates [will be released][2], the Fedora package will receive updates. No need to compile your own development version of Python, just install it and have it up to date. The Python developers will add no new features starting with the first beta; you can already enjoy all the new things.
### Test your projects with Python 3.10
Run the _python3.10_ command to use Python 3.10 or create virtual environments with the [builtin _venv_ module, tox][3] or with [pipenv][4] and [poetry][5]. Heres an example using _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 :)
```
If you find a problem with Python 3.10 on Fedora Linux, please do [file bug reports at Fedoras bugzilla][6] or in the [Pythons issue tracker][7]. If you arent sure if it is a problem in Python, you can [contact the Fedoras Python maintainers][8] directly via email or IRC.
### Whats new in Python 3.10
See the [full list of news in Python 3.10][9]. You can, for example, try out [structural pattern matching][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
```
And stay tuned for [Python 3.10 as _python3_ in Fedora Linux 35][11]!
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/
作者:[Miro Hrončok][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者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