Python 语法错误:没有机会
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17811855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Syntax Error: Not a Chance
提问by Anurag-Sharma
I tried executed the following code in the python IDLE
我尝试在 python IDLE 中执行以下代码
from __future__ import braces
And I got the following error:
我收到以下错误:
SyntaxError: not a chance
What does the above error mean?
上面的错误是什么意思?
采纳答案by Martijn Pieters
You have found an easter egg in Python. It is a joke.
您已经在 Python 中找到了一个复活节彩蛋。这是一个笑话。
It means that delimiting blocks by braces instead of indentation will never be implemented.
这意味着永远不会实现用大括号而不是缩进来分隔块。
Normally, imports from the special __future__
moduleenable features that are backwards-incompatible, such as the print()
function, or true division.
通常,从特殊__future__
模块导入会启用向后不兼容的print()
功能,例如函数或真正的除法。
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 everhappening are nil.
因此,线from __future__ import braces
被认为是指你要启用该功能“用括号来创建块”,异常告诉您那的机会不断发生的零。
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!
您可以将其添加到 Python 中包含的长长的笑话列表中,就像import __hello__
、import this
和 一样import antigravity
。Python 开发者的幽默感非常发达!
回答by zhangyangyu
The __future__
module is normally used to provide features from future versions of Python.
该__future__
模块通常用于提供 Python 未来版本的功能。
This is an easter egg that summarizes its developers' feelings on this issue.
这是一个彩蛋,总结了开发者对这个问题的感受。
There are several more:
还有几个:
import this
will display the zen of Python.
import this
将展示 Python 之禅。
import __hello__
will display Hello World...
.
import __hello__
将显示Hello World...
.
In Python 2.7 and 3.0, import antigravity
will open the browser to a comic!
在 Python 2.7 和 3.0 中,import antigravity
浏览器会打开一个漫画!