Zen of Python

The Zen of Python is a collection of 19 "guiding principles" for writing computer programs that influence the design of the Python programming language. Python code that aligns with these principles is often referred to as "Pythonic".

Software engineer Tim Peters wrote this set of principles and posted it on the Python mailing list in 1999. Peters' list left open a 20th principle "for Guido to fill in", referring to Guido van Rossum, the original author of the Python language. The vacancy for a 20th principle has not been filled.

Peters' Zen of Python was included as entry number 20 in the language's official Python Enhancement Proposals and was released into the public domain. It is also included as an Easter egg in the Python interpreter, where it can be displayed by entering.

In May 2020, Barry Warsaw (developer of GNU Mailman) wrote the lyrics to music.

Principles
The principles are listed as follows:

 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 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!

Being Pythonic
One of the principles, "There should be one-- and preferably only one --obvious way to do it", can be referenced as the "Pythonic" way. The official definition of "Pythonic" is: An idea or piece of code which closely follows the most common idioms of the Python language, rather than implementing code using concepts common to other languages. For example, a common idiom in Python is to loop over all elements of an iterable using a  statement. Many other languages don’t have this type of construct, so people unfamiliar with Python sometimes use a numerical counter instead: As opposed to the cleaner, Pythonic method: Code that is difficult to understand or reads like a rough transcription from another programming language is called unpythonic.

In practice
Since the release of the Zen of Python, there has been research done on its effectiveness and actual use among developers. Despite the difference in interpretation between beginners and experienced Python programmers, interviews among 13 Python programmers of varying skill show that the Zen of Python "positively influences the way developers write and talk about code". Researchers extended this case study to explore the use of Python idioms on GitHub repositories, and found that the usage of "Pythonic idioms" increased over time. Writing Python code that aligns with the Zen of Python may save memory and run time of Python programs. The desire to write in Pythonic code has led to refactoring tools to help programmers achieve this goal.