Mike Driscoll Profile picture
Python Book author, blogger, and more @ThePSF #Python

Nov 27, 2022, 10 tweets

#Python has several Easter eggs built in! 🐍πŸ₯šπŸ£πŸ‡

An Easter egg is a fun little surprise in a programming language, video game or movie.

Let's talk about some of Python's cool Easter eggs!

πŸ§΅πŸπŸ‘‡

πŸ₯š1️⃣ - The most famous #Python Easter egg is probably The Zen of Python, which you will see if you "import this"

πŸ₯š2️⃣ - What you might not know is that Zen of Python's source is really interesting too:

github.com/python/cpython…

πŸ₯š3️⃣ - The next most well-known Easter egg in #Python is probably "import antigravity"

If you type that in your Python REPL, you will be taken to this XKCD comic: xkcd.com/353/

πŸ₯š4️⃣ - Create "Hello World" with an import in #Python!

πŸ₯š5️⃣ - Let's try and import braces in #Python!

Nope! That Easter Egg won't let us!

πŸ₯š6️⃣ - This Easter Egg is kind of tricky. It's for the math nerds in #Python

If you hash infinity in Python, you get back a representation of Pi

If you hash NAN, you will get zero

πŸ₯š7️⃣ - Barry Warsaw, a longtime #Python core developer, was nominated "Friendly Language Uncle For Life" or FLUFL

If you do this special import, the inequality operator "!=" is replaced with "<>"

There are a few other Easter eggs mentioned in this curated list of Easter Eggs in Python on GitHub:

github.com/OrkoHunter/pyt…

Thanks for reading my fun little thread on #Python Easter eggs! πŸπŸ‡πŸ₯š

Follow me for more neat content on the Python language!

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling