Hello World
I guess nearly everyone who ever got in touch with Python wrote the famous 'Hello World' program in Python, or at least know how to code it. But there is another easy way besides printing it, you can also use the built-in implementation:
>>> import __hello__Hello world!
The Zen of Python
This easter egg is probably the most known one, at least the experienced Python programmers are likely to know it. Tim Peters created 20 guiding principles, 19 ones are written down as the Zen of Python. This feature is also documented in the PEP 20 guideline.
The Zen of Python is telling Python's philosophy and best practices. The message is mainly about code quality, design, and how to solve problems. If you follow them, you will improve your code and the way you solve problems.
You can see the Zen of Python by importing the module this, try it out!
>>> import this
Indeed, there is another awesome aspect of this easter egg. If you are interested, take a look at the source code file of the module this.
Uncle Barry
In the evolving process of Python, the debate of the inequality operator implementation had two opposite sides some time ago. The != version finally won the battle against the diamond operator >< to avoid any ambiguity and improve the readability.
The well-known Python programmer Barry Warsaw (aka Uncle Barry) had the honor to become the Friendly Language Uncle For Life (FLUFL). Sadly, he is on the losing side of the debate and prefers the version for the inequality operator. But if you have the same vision as Uncle Barry, you can simply import a library to change the rules and use the other variant!
>>> from __future__ import barry_as_FLUFL>>> 0 != 1SyntaxError: with Barry as BDFL, use '<>' instead of '!='>>> 0 <> 1True>>> 1 <> 1False
Using the official inequality operator then raises a SyntaxError, you have to use the other operator instead. As an April fool, PEP 401 says that this operator got enacted by the FLUFL in 2009 (and some other stupid changes).
Braces
One of the most amazing differences between coding in Python and most of the other programming languages (Java, C++, JavaScript, etc.) is the following: No curly braces! (except for dicts and sets, but they don't count). I think everyone who had to deal with a code containing thousands of curly braces will appreciate the simplicity of Python with nothing more than indentations. It's just easier and more readable without curly braces, so Python wants to show that they aren't tolerated in the language.
You can try to import the braces from the __future__ build-in module if you can't resist the temptation to use them, but look what happens:
>>> from __future__ import bracesSyntaxError: not a chance
Antigravity
You can experience antigravity by Python coding, believe me! Just run the following code and see what appears on your screen:
>>> import antigravity
Hash
Is it possible to create a hash of infinity or a NaN value? In Python it is!
>>> hash(float('inf'))314159>>> hash(float('nan'))0
Monty Python References
The Name Python is an homage to the English comedy group Monty Python. Furthermore, the docs say that the language is named after the BBC show “Monty Python's Flying Circus”.
There are some references to Monty Python jokes hidden in the whole Python environment, here are a few examples:
- Funny quote of Monty Python and the Holy Grail in the official input and output documentation
- Instead of using foo and bar, many tutorials use spam and egg
- The name of the wheel ZIP-format for Python's sdist packages is based on the Cheese Shop sketch by Monty Python
These are a few Monty Python reference easter eggs, I am sure you can find more by exploring the Python documentation and tutorials!
I presented some cool and funny easter eggs you can find by using Python, I hope you enjoyed it! If you want to explore more funny and interesting Aspects of Python, you can take a look at the Python Humor page in the documentation. If you have any feedback or another cool easter egg that is still missing here, let me know in the comments below!