gpt4 book ai didi

python - 可以使用 __future__ 在 Python 3.7 中启用赋值表达式吗?

转载 作者:太空狗 更新时间:2023-10-29 22:28:35 24 4
gpt4 key购买 nike

Python 3.8 引入了赋值表达式,描述见 PEP 572 .有没有办法在 Python 3.7.x 中测试这个新功能?

过去,新的语言特性已使用 __future__ 向后移植到早期的 Python 版本进口。

  • 是否有用于赋值表达式的 __future__ 导入?
  • 如果是,功能名称是什么?
  • 如果没有,是否有计划添加它? (3.7 即将推出一段时间)

最佳答案

Python 3.7 中没有__future__ 导入赋值表达式——PEP 6 禁止在微(或“bugfix”)版本中添加一个。 :

Prohibitions

Bug fix releases are required to adhere to the following restrictions:

  1. There must be zero syntax changes. All .pyc and .pyo files must work (no regeneration needed) with all bugfix releases forked off from a major release.

Applicability of Prohibitions

The above prohibitions and not-quite-prohibitions apply both for a final release to a bugfix release (for instance, 2.4 to 2.4.1) and for one bugfix release to the next in a series (for instance 2.4.1 to 2.4.2).

由于赋值表达式构成了对 Python 语法的更改,因此在不违反此禁令的情况下无法将它们添加到 Python 的 future 3.7.x 版本中。

关于python - 可以使用 __future__ 在 Python 3.7 中启用赋值表达式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51585995/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com