in Programming, Python, Tutorial

The Top 5 Easter Eggs in Python

Despite being a very serious language, Python is full of Easter eggs and hidden references. This post shows the top 5:

  1. Hello World…
  2. The Zen of Python
  3. Antigravity
  4. C-Style braces instead of indentation
  5. Monthy Python references

I have covered the 5 most interesting features of Python in this post.

1. Hello World…

As a programmer, you should be familiar with Hello World. Python has a library that does that that.

>>> import __hello__
Hello World...

On Python 3 you get a slightly more enthusiastic message: Hello world!. Reimporting the library doesn’t make the message reappear.

2. The Zen of Python

Another hidden library in Python is this, which prints a poem by Tim Peters called The Zen of Python:

>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

3. Antigravity

The most infamous easter egg in Python is the antigravity one, which redirects to an xkcd strip:

import antigravity


4. C-Style braces instead of indentation

Python is designed to be elegant; mandatory indentation is an essential part of this. The library braces were supposed to change this, allowing to use C-Style braces instead of indentation. This is of course a joke, since attempting to import it produces a rather passive-aggressive “not a chance“.

>>> from __future__ import braces
  File "<stdin>", line 1
SyntaxError: not a chance

5. Monthy Python references

The name Python has nothing to do with reptiles. Rather the opposite, it comes from the BBC show “Monty Python’s Flying Circus”. As the official Python guide suggests:

Making references to Monty Python skits in documentation is not only allowed, it is encouraged!

This has led developers to include several hidden references not only in the official documentation, but also in their code. For instance in Python, metasyntactic variables takes the names of spam and egg, rather than the more traditionally used foo and bar. This is a clear reference to the Monty Python sketch Spam. You can see this, for example, in the official documentation (Input and otuput) in which there are many other references such as:

>>> print 'We are the {} who say "{}!"'.format('knights', 'Ni')
We are the knights who say "Ni!"

From Coursera to Codeacademy, basically every serious Python tutorial make references to Monty Python.

💖 Support this blog

This website exists thanks to the contribution of patrons on Patreon. If you think these posts have either helped or inspired you, please consider supporting this blog.

Patreon Patreon_button

📧 Stay updated

You will be notified when a new tutorial is released!

📝 Licensing

You are free to use, adapt and build upon this tutorial for your own projects (even commercially) as long as you credit me.

You are not allowed to redistribute the content of this tutorial on other platforms, especially the parts that are only available on Patreon.

If the knowledge you have gained had a significant impact on your project, a mention in the credit would be very appreciated. ❤️🧔🏻

Write a Comment


    • if you do that you get this:
      Ornhgvshy vf orggre guna htyl.
      Rkcyvpvg vf orggre guna vzcyvpvg.
      Fvzcyr vf orggre guna pbzcyrk.
      Pbzcyrk vf orggre guna pbzcyvpngrq.
      Syng vf orggre guna arfgrq.
      Fcnefr vf orggre guna qrafr.
      Ernqnovyvgl pbhagf.
      Fcrpvny pnfrf nera’g fcrpvny rabhtu gb oernx gur ehyrf.
      Nygubhtu cenpgvpnyvgl orngf chevgl.
      Reebef fubhyq arire cnff fvyragyl.
      Hayrff rkcyvpvgyl fvyraprq.
      Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.
      Gurer fubhyq or bar– naq cersrenoyl bayl bar –boivbhf jnl gb qb vg.
      Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh’er Qhgpu.
      Abj vf orggre guna arire.
      Nygubhtu arire vf bsgra orggre guna *evtug* abj.
      Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg’f n onq vqrn.
      Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
      Anzrfcnprf ner bar ubaxvat terng vqrn — yrg’f qb zber bs gubfr!

  1. and try this:

    import this

    for c in this.s:
    if c in this.d:

  2. Thankyou fo sharing such an informative post. It was really helpful. The title “The Top 5 Egg Easter” is itself looks very interesting that made me click on your blog. And after reading your blog I feel your writing style is so smooth and its really easy to understand. And those drawing made it more interesting.


  • Tutorial Series - Alan Zucconi May 24, 2022

    […] The Top 5 Easter Eggs in Python […]