TranslateProject/sources/tech/20210623 Python 3.10 beta in Fedora Linux.md
2021-06-25 08:56:33 +08:00

4.3 KiB
Raw Blame History

Python 3.10 beta in Fedora Linux

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, 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 or with pipenv and poetry. 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 or in the Pythons issue tracker. If you arent sure if it is a problem in Python, you can contact the Fedoras Python maintainers directly via email or IRC.

Whats new in Python 3.10

See the full list of news in Python 3.10. You can, for example, try out structural pattern matching:

$ 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!


via: https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/

作者:Miro Hrončok 选题:lujun9972 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出