Python's simplicity philosophy

Dave Brueck dave at pythonapocrypha.com
Tue Nov 11 13:59:38 EST 2003


> >> > Part of the problem here is that just saying "only one way to do
> >> > it" is a horrible misquote, and one that unfortunately misses IMO
> >> > some of the most important parts of that "mantra":
>
> >> Well, perhaps anything like "only one way to do it" should be removed
> >> from the mantra altogether, since people keep misquoting it in order
> >> to support their position of removing beautiful features like reduce()
> >> from the language.
>
> > You're joking, right? It is one of the key aspects of Python that makes
the
> > language such a good fit for me. Changing the philosophy because a *few*
> > people don't "get it" or because they are apt to misquote it seems
crazy.
>
> Of course I am not joking.  I see no good coming from the mantra, when
> the mantra should be instead what I said it should be:

Nah, I don't really like your version. Also, the "only one way to do it"
misquote has been singled out when it really should be considered in the
context of the other items in that list - for whatever reason (maybe to
contrast with Perl, I don't know) it's been given a lot of weight in c.l.py
discussion threads.

> "small, clean, simple, powerful, general, elegant"

It's really a matter of taste - both "versions" mean about the same to me
(and to me both mean "get rid of reduce()" ;-) ).

> To me, there is never *one* obviously "right way" to do anything

Never? I doubt this very much. When you want to add two numbers in a
programming language, what's your first impulse? Most likely it is to write
"a + b". The same is true of a lot of other, even much more complex, things.
And IMO that's where this principle of an obvious way to do things comes
into play, and it's tightly coupled with the principle of least surprise. In
both cases they are of course just guiding principles or ideals to shoot
for, so there will always be exceptions (not to mention the fact that what
is obvious to one person isn't universal, in the same way that "common
sense" is rarely common).

Having said that though, part of the appeal of Python is that it hits the
nail on the head surprisingly often: if you don't know (from prior
experience) how to do something in Python, your first guess is very often
correct. Correspondingly, when you read someone else's Python code that uses
some feature you're not familiar with, odds are in your favor that you'll
correctly guess what that feature actually does.

And that is why I wouldn't be sad if reduce() were to disappear - I don't
use reduce() and _anytime_ I see reduce() in someone's code I have to slow
way down and sort of rehearse in my mind what it's supposed to do and see if
I can successfully interpret its meaning (and, when nobody's looking, I
might even replace it with a for-loop!). Of course that would be different
if I had a history of using functional programming languages, which I don't.
That's the line Guido walks: trying to find just the right combination of
different-but-better and intuitive-for-most-people, and the aforementioned
items from the Zen of Python are a way of expressing that.

-Dave






More information about the Python-list mailing list