Easter Eggs
Users of curly bracket programming languages, such as C or Java, sometimes expect or wish Python to follow a block-delimiter convention. Brace-delimited block syntax has been repeatedly requested, and consistently rejected by core developers. The Python interpreter contains an easter egg that summarizes its developers' feelings on this issue. The code from __future__ import braces
raises the exception SyntaxError: not a chance
. The __future__
module is normally used to provide features from future versions of Python.
Another hidden message, The Zen of Python (a summary of Python philosophy), is displayed when trying to import this
.
The message Hello world!
is printed when the import statement import __hello__
is used. In Python 2.7, instead of Hello world!
it prints Hello world...
.
An antigravity
module was added to Python 2.7 and 3.0. Importing it opens a web browser to an xkcd comic that portrays a humorous fictional use for such a module, intended to demonstrate the ease with which Python modules enable additional functionality.
The statement "from __future__ import barry_as_FLUFL" is named after Barry Warsaw and replaces the != operator with the <> operator.
Read more about this topic: Python Syntax And Semantics
Famous quotes containing the words easter and/or eggs:
“Why wont they let a year die without bringing in a new one on the instant, cant they use birth control on time? I want an interregnum. The stupid years patter on with unrelenting feet, never stoppingrising to little monotonous peaks in our imaginations at festivals like New Years and Easter and ChristmasBut, goodness, why need they do it?”
—John Dos Passos (18961970)
“Nothing is so beautiful as spring
When weeds, in wheels, shoot long and lovely and lush;
Thrushs eggs look little low heavens, and thrush
Through the echoing timber does so rinse and wring
The ear, it strikes like lightning to hear him sing.”
—Gerard Manley Hopkins (18441889)