语法错误:不是机会

问题:语法错误:不是机会

我尝试在python IDLE中执行以下代码

from __future__ import braces 

我得到了以下错误:

SyntaxError: not a chance

上述错误是什么意思?

I tried executed the following code in the python IDLE

from __future__ import braces 

And I got the following error:

SyntaxError: not a chance

What does the above error mean?


回答 0

您已经在Python中找到了一个复活节彩蛋。开个玩笑。

这意味着永远不会实现用大括号而不是缩进来分隔块。

通常,从特殊__future__模块导入会启用向后不兼容的print()功能,例如功能或真正的划分。

因此,线from __future__ import braces被认为是指你要启用该功能“用括号来创建块”,异常告诉您那的机会不断发生的零。

您可以添加到包括在Python中-笑话的一大串,就像import __hello__import thisimport antigravity。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.

Normally, imports from the special __future__ module enable features that are backwards-incompatible, such as the print() function, or true division.

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.

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!


回答 1

__future__模块通常用于提供Python未来版本的功能。

这是一个复活节彩蛋,总结了开发人员在此问题上的感受。

还有更多:

import this 将显示Python的禅宗。

import __hello__将显示Hello World...

在Python 2.7和3.0中,import antigravity将打开浏览器以显示漫画!

The __future__ module is normally used to provide features from future versions of 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 __hello__ will display Hello World....

In Python 2.7 and 3.0, import antigravity will open the browser to a comic!