[ad_1]
Python 开发人员已经发布了 Python 3.9.0 的五个 alpha 版本,您已经可以在 Fedora! 尽早使用 3.9 测试您的 Python 代码,以避免在 10 月份最终 3.9.0 发布后出现意外。
安装 Python 3.9 Fedora
如果你跑 Fedora,您可以使用 dnf 从官方软件存储库安装 Python 3.9:
$ sudo dnf install python3.9
为了获得最新的预发布版本,您可能需要启用更新测试存储库:
$ sudo dnf install --enablerepo=updates-testing python3.9
随着越来越多的 alpha、beta 和候选发布 Python 3.9 将发布, 这 Fedora 包将收到更新。 无需编译您自己的 Python 开发版本,只需安装它并使其保持最新。 新功能将添加到第一个 beta 计划在五月中旬。
使用 Python 3.9 测试您的项目
运行 python3.9 命令以使用 Python 3.9 或使用 内置 venv 模块,tox 或使用 pipenv 和 诗歌. 例如:
$ git clone https://github.com/benjaminp/six.git Cloning into 'six'... $ cd six/ $ tox -e py39 py39 run-test: commands[0] | python -m pytest -rfsxX ================== test session starts =================== platform linux -- Python 3.9.0a5, pytest-5.4.1, py-1.8.1, pluggy-0.13.1 collected 200 items test_six.py ...................................... [ 19%] .................................................. [ 44%] .................................................. [ 69%] .................................................. [ 94%] ............ [100%] ================== 200 passed in 0.43s =================== ________________________ summary _________________________ py39: commands succeeded congratulations :)
Python 3.9 中的新功能
到目前为止,前五个 alpha 已经发布, 更多功能会出现 直到第一个 beta. 但是,您已经可以尝试新的 字典合并和更新运算符:
$ python3.9 Python 3.9.0a5 (default, Mar 24 2020, 00:00:00) [GCC 10.0.1 20200311 (Red Hat 10.0.1-0.9)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> d = {'spam': 1, 'eggs': 2, 'cheese': 3} >>> e = {'cheese': 'cheddar', 'aardvark': 'Ethel'} >>> d | e {'spam': 1, 'eggs': 2, 'cheese': 'cheddar', 'aardvark': 'Ethel'} >>> e | d {'cheese': 3, 'aardvark': 'Ethel', 'spam': 1, 'eggs': 2} >>> d |= e >>> d {'spam': 1, 'eggs': 2, 'cheese': 'cheddar', 'aardvark': 'Ethel'}
并继续关注 Python 3.9 作为 python3 中的 Fedora 33!
[ad_2]