Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Error: Not a Chance - What is this error?

I tried to execute the following code on a Python IDLE

from __future__ import braces 

And I got the following error:

SyntaxError: not a chance

What does the above error mean?

like image 507
Anurag-Sharma Avatar asked Jul 23 '13 13:07

Anurag-Sharma


People also ask

What is syntax error in Python with example?

Syntax errors are mistakes in the use of the Python language, and are analogous to spelling or grammar mistakes in a language like English: for example, the sentence Would you some tea? does not make sense – it is missing a verb. Common Python syntax errors include: leaving out a keyword.

Can I use braces in Python?

In fact, Python supports curly braces, BEGIN/END, and almost any other language's block schemes: see python.org/doc/humor/…!


Video Answer


2 Answers

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!

like image 93
Martijn Pieters Avatar answered Oct 08 '22 19:10

Martijn Pieters


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!

like image 25
zhangyangyu Avatar answered Oct 08 '22 18:10

zhangyangyu