Dijkstra on Python
imbosol at vt.edu
Tue Aug 13 12:13:42 CEST 2002
James J. Besemer wrote:
I'm sorry, chief, but you are seriously missing the point here.
First of all, the word "always" is not part of the motto, although you
seem to be arguing under the premise that it is. Try importing "this"
for the canonical (I suppose) version of the statement: "There should
be one-- and preferably only one --obvious way to do it."
When Pythonistas say "there should be only one obvious way to do it,"
we are not saying, "this is how Python is." We are saying, "this is
what our programming philosophy is."
When Perlochists say "there's more than one to do it," they are not
saying, "this is how Perl is." They are saying, "this is what our
programming philosophy is."
The fact is, both mottos can apply to both languages. There certainly
is more than one way to do it in Python.
And, even in Perl, there is often only one obvious way to do it. For
example, take a look at the perlsyn manpage, in the section called
"Basic BLOCKs and Switch Statements." The section exemplifies several
different ways to do switch statements, but guess what? There's only
one obvious way (and naturally it was the way that was discouraged).
And that really governs the language design of Python. It means that
all sinewy little tricks are not strewn through the syntax. Perhaps a
better motto would be, "if there's an obvious way to do it, there
doesn't need to be another way." Or maybe, "you should do it the
obvious way." But those, of course, don't contrast as well with
And finally, whether you want to believe it or not, when Pythonistas
say "there should be only one obvious way to do it," we really are
talking about common idioms like for loops and switch statements. No
one is talking about sets when they say it.
More information about the Python-list