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.

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:

3. Antigravity

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

python

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“.

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:

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

💖 Support this blog

This websites 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.

Twitter_logo

YouTube_logo
📧 Stay updated

You will be notified when a new tutorial is relesed!

📝 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

Comment

  1. and try this:

    import this

    print()
    for c in this.s:
    if c in this.d:
    print(this.d[c],end=”)
    else:
    print(c,end=”)
    print()

Webmentions

  • Tutorial Series - Alan Zucconi December 23, 2019

    and try this:

    import this

    print()
    for c in this.s:
    if c in this.d:
    print(this.d[c],end=”)
    else:
    print(c,end=”)
    print()