The Zen of Python

The Zen of Python
Every experienced programmer has a favourite language, and a not-so-favourite language. Lewis loves Java — that’s why he develops and presents all the Java-related courses. I once heard Renier describe C as being like poetry. But I think very few programming languages have inspired as much passion and playfulness as Python.

Pythonic People

For example, Python has inspired a fascinating new set of ways to describe people and code. Here are some new definitions to add to your vocabulary:
  • A Pythonista is a Python loyalist: some one who is passionate about the Python programming language.
  • A Pythoneer is an expert (and passionate) Python programmer – think “Python” plus “engineer”. This is often someone who contributes to the range of useful modules available for Python.
  • Pythonic is used to describe code that follows the conventions and philosophy of Python.
Do you know of any such terms for Java programmers or .NET programmer or web developers? I certainly don’t. I think it’s only a matter of time until we have a new verb like “to py” or “to python” . After all, we now all use “google” as a verb.

The Zen of Python

You’ve probably heard the phrase “the Zen of …”. Technically, Zen is a form of Buddhism that emphasizes self-control, meditation, mindfulness and personal insight, rather than religious doctrine. Zen is about being completely present. When we tell people to zen, we mean they should relax and not worry about things they cannot change. Tim Peters wrote a poem called “The Zen of Python”. It is built into the Python interpreter. (The interpreter is the program that “translates” Python code into binary and executes it.) To find it, just type import this in the Python interpreter. If you haven’t installed Python, here is the poem:
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!
As a poem, I think it has very little artistic merit. But it does tell you a lot about the philosophy of Python (and the requirements to be Pythonic). And some of the lines actually describe good principles, for life and for programming. Like this one:
In the face of ambiguity, refuse the temptation to guess.

Fly with Python

Here is another slightly weird, but entertaining, fact about Python. If you use the default Python integrated development environment, called IDLE, you can type in the following: import antigravity The result? It opens a web page with a comic about the antigravity module.
Cartoon from xkcd about the antigravity module in Python

What about the snake?

People often ask why the language is named after a snake. The simple answer: it isn’t. The name has nothing to do with the snake. Guido van Rossum, a Dutch programmer, created the Python programming language. While he was working on it, he was reading scripts from an off-beat 1970s BBC comedy series called “Monty Python’s Flying Circus”. He wanted a short, unique and slightly mysterious name for his language. So, inspired by the series, he named it Python. This also explains why the Python Package Repository — PyPi — is sometimes called “The Cheese Shop”. This is a reference to a Monty Python sketch. Just to confuse this, the Python Software Foundation describes the official logo as “two snakes”. I think it looks a little “yin-yang” – which might (but probably doesn’t) explain the Zen poem.

Conclusion

Actually I don’t have a conclusion. I just wanted to share some of this fascinating Python trivia.

Leave a Comment

Your email address will not be published. Required fields are marked *

Thank You

We're Excited!

Thank you for completing the form. We're excited that you have chosen to contact us about training. We will process the information as soon as we can, and we will do our best to contact you within 1 working day. (Please note that our offices are closed over weekends and public holidays.)

Don't Worry

Our privacy policy ensures your data is safe: Incus Data does not sell or otherwise distribute email addresses. We will not divulge your personal information to anyone unless specifically authorised by you.

If you need any further information, please contact us on tel: (27) 12-666-2020 or email info@incusdata.com

How can we help you?

Let us contact you about your training requirements. Just fill in a few details, and we’ll get right back to you.