Syntax Error: Not a Chance

后端 未结 2 1428
失恋的感觉
失恋的感觉 2021-01-30 04:42

I tried executed the following code in the python IDLE

from __future__ import braces 

And I got the following error:



        
相关标签:
2条回答
  • 2021-01-30 05:26

    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!

    0 讨论(0)
  • 2021-01-30 05:38

    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!

    0 讨论(0)
提交回复
热议问题