[Python-ideas] Addition to the Zen of python

Mike Meyer mwm-keyword-python.b4bdba at mired.org
Sat Oct 3 01:50:49 CEST 2009

On Fri, 2 Oct 2009 13:18:03 +0100
Paul Moore <p.f.moore at gmail.com> wrote:
> I'm not sure there is a corresponding design principle within Python
> that all constructs should be fully general (which is basically the
> principle you're appealing to). I can't immediately find
> counterexamples, though, so there may be a point there. But certainly,
> I'd say that such a principle (if it exists) isn't as well-established
> as the "no line noise" one (witness comments like "if you want Perl,
> you know where to get it"...)

This principle is know in Unix circles as "POLA" - the "Principle Of
Least Astonishment".

I think it's an important part of what makes Python Python - when you
do something that seems obvious, it very seldom astonishes you. I'm
not sure why Tim didn't include it in the Zen; my gut says that it's
because this is an even more fundamental part of the landscape than
most of the things on the list, so he overlooked it, but I'd rather he
speaks for himself.

So I propose amending the Zen of Python (as from "import this") to
include it, as so:

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.
The obvious way should not produce astonishing results.
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!

Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

More information about the Python-ideas mailing list