Python's simplicity philosophy

Terry Reedy tjreedy at udel.edu
Mon Nov 17 21:12:39 EST 2003


"Alex Martelli" <aleax at aleax.it> wrote in message
news:p15ub.34009$9_.1358080 at news1.tin.it...
> Terry Reedy wrote:
>
> Hmmm, nobody else seemed to have any problem understanding my quip,

Among those who dared respond ...

> including the poster at which it was directed.  Let me spell it out
for you:

Since, as I said, your target was obscure to me, thank you...

> a few people are attacking 'sum' and defending 'reduce'
> because the latter is "more general".

Oh.... so that was your target.

Since reduce with initializer is completely general, equivalent to an
initialized for loop (which is why I might instead call it 'induce' or
'repeat'), and hence as or more general than max, min, range,
enumerate, map, filter, list.count, and man other functions and
methods, and since none of these other 'less general than reduce'
functions have been similarly attacked that I have noticed, the
special-case, ad-hominen-like attacks on 'sum' had mostly passed
beneath my notice as devoid of memorable content.

A consistent preference for either or both of 'more general' and 'only
one way to do it' might lead us toward a very lean Python with exactly
one general repetition-with-variation function -- either 'for'
statements or something equivalent to reduce with required
initializer.  But I have not noticed anyone proposing that.

> So, no, I don't think my idea of "more general" is different from
> yours: e.g., a function that, given a sequence, returns its length
> AND the number of times 'None' occurs as an item, is more general
> than one which just returns the length.  That does not make it in
> any intrinsic way "necessarily preferable" -- and THAT is my point.

Agreed.  Generic versus specific involves tradeoff and balance.

In my garage-workshop tool set, I have perhaps 10 different general
(adjustable) wrenches, pliers, and grips, 5 specialize (fixed-size)
box-end wenches, and perhaps 30 sockets (both metric and 'English').
I have used most of them except for the large sockets meant for auto
and truck work I don't do.  So I am glad to have all of them.

Terry J. Reedy






More information about the Python-list mailing list