[Python] The Zen of Python

Tadashi Shigeoka ·  Wed, April 18, 2012

I’d like to introduce “The Zen of Python” which beautifully expresses the essential truths of Python.

Python
The Zen of Python 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!

PEP 20 — The Zen of Python

The Zen of Python

Beautiful is better than ugly

Clear and straightforward is better than messy and complicated

Simple is better than troublesome

But if it becomes incomprehensible, troublesome is better

If you don’t need to nest, it’s better not to

Sparse is better than densely packed

Readability is important

There are special cases, but not enough to break the rules

When pursuing practicality, you might deviate a little, but that’s okay

Unless you’re doing it on purpose

Errors should never pass silently

Don’t handle ambiguous things casually

There should be one foolproof way to do it

Even if it might be a bit unclear to non-Dutch people

Better to do it now than not at all

But sometimes it’s better not to do it than to do it “right” now

If you can’t explain what you’re making well, then it’s a no-go

If you can explain it well, then it’s probably good

Namespaces are a brilliant idea, let’s do more of those

The Zen of Python

That’s all from the Gemba.