Python's simplicity philosophy

Douglas Alan nessus at
Sat Nov 15 03:15:34 CET 2003

"Dave Brueck" <dave at> writes:

>> You just have to be taught by people who don't think
>> that something as simple as reduce() is beyond your abilities.

> Nobody in this entirely too-long thread has asserted such a thing.

There *have* been postings that have asserted that reduce() is
difficult to learn.  But it is not.  I learned it when I was in high
school with no trouble and no background.  I've already posted a
perfectly good description of reduce() that anyone should be able to
learn in under a minute.  And if despite this, someone finds reduce()
difficult to learn, then perhaps this is particularly the kind of
thing they that *should* be learning, so that such things will no
longer be difficult for them.

> You have inferred from people saying that it's non-obvious or less
> readable than other constructs that they mean it's difficult to
> teach or that people are too stupid to learn it. Nothing could be
> farther from the truth.

Neither is sum() obvious until you know what it does.  Perhaps it is
it just a synonym for add?  Or maybe it produces summaries of some
sort.  What happens if you give it an empty list?  In the time that
you can answer these questions for yourself, you can have figured out
the more general tool, reduce(), and once you have, then it is just as
obvious and readable as sum(), only it has other uses as well.

> It's not that reduce is hard to learn - it's just that there are
> simpler and clearer constructs that do the same thing and are more
> readable to most people.  That's it!

Well, bah!  There are precious few constructs in this world that are
clearer and more readable than

   reduce(add, seq)


More information about the Python-list mailing list