问题描述
我尝试在 Python IDLE 上执行以下代码
I tried to execute the following code on a Python IDLE
from __future__ import braces
我收到以下错误:
SyntaxError: not a chance
上述错误是什么意思?
推荐答案
您在 Python 中发现了一个彩蛋.开个玩笑.
You have found an easter egg in Python. It is a joke.
这意味着永远不会实现用大括号而不是缩进来分隔块.
It means that delimiting blocks by braces instead of indentation will never be implemented.
通常,从特殊__future__ 模块
启用向后不兼容的功能,例如 print()
函数或真正的除法.
Normally, imports from the special __future__
module enable features that are backwards-incompatible, such as the print()
function, or true division.
因此,from __future__ import braces
行表示您要启用使用大括号创建块"功能,并且异常告诉您永远 发生的都是零.
So the line from __future__ import braces
is taken to mean you want to enable the 'create blocks with braces' feature, and the exception tells you your chances of that ever happening are nil.
您可以将其添加到 Python 中包含的长长的笑话列表中,就像 import __hello__
、import this
和 import antigravity
.Python 开发者的幽默感很强!
You can add that to the long list of in-jokes included in Python, just like import __hello__
, import this
and import antigravity
. The Python developers have a well-developed sense of humour!
这篇关于语法错误:不是机会 - 这是什么错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!