166

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?

wovano
  • 4,543
  • 5
  • 22
  • 49
Anurag-Sharma
  • 4,278
  • 5
  • 27
  • 42

3 Answers3

221

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!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • 25
    For folks puzzled by "not a chance", which is slang, it means that there is no possibility or probability of the thing happening. – DOK Jul 23 '13 at 13:43
  • I ask myself if it would be theoretically possible to implement that - as an extension - in python. (I'm not a python developer) – hek2mgl Jul 23 '13 at 13:45
  • 1
    @hek2mgl http://writeonly.wordpress.com/2010/04/01/whython-python-for-people-who-hate-whitespace/ – chepner Sep 23 '14 at 16:06
  • 3
    @chepner `Less Whitespace, More Enterprise` :D Thanks! – hek2mgl Sep 23 '14 at 16:22
  • 2
    It's less funny for blind people trying to deal with Python on a screen reader. For them the reliance on white-space for blocks makes reading and writing code difficult. At least that's been my experience working with blind kids. – dumbledad Jul 12 '18 at 09:09
  • @dumbledad that was perhaps true a decade ago, but screen readers have since learned to voice indentation information. – Martijn Pieters Jul 12 '18 at 09:21
  • Have they - JAWS seems not to cope well. I'll do more research. Which one were you using for well voiced indentation information? – dumbledad Jul 12 '18 at 10:02
  • @dumbledad: All my experience is indirect, but I heard positive stories supporting NVDA, EdSharp and Orca; I note that both Orca and NVDA are primarily written in Python! Also, Python is not the only programming language with significant whitespace. – Martijn Pieters Jul 12 '18 at 10:56
  • Nope, COBOL too. Both for the same reason (as far as I can tell): readability – dumbledad Jul 12 '18 at 13:05
  • 3
    @dumbledad: Haskell, CoffeeScript, Miranda, Occam, and F# all use whitespace in the syntax. Note: this comment thread is getting way out of hand; please join the [Python chat room](https://chat.stackoverflow.com/rooms/info/6/python) if you want to discuss further. – Martijn Pieters Jul 12 '18 at 13:18
38

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!

zhangyangyu
  • 8,520
  • 2
  • 33
  • 43
2

It means that writing Python code like:

def hello() {
    print("Hello");
    print("World");
}

instead of

def hello():
    print("Hello")
    print("World")

will never happen. One is both faster to type and easier to understand. Can you tell which one?

Oh, and someone made this.

Gugalcrom123
  • 101
  • 1
  • 9