Python's simplicity philosophy

Alex Martelli aleax at aleax.it
Mon Nov 17 09:36:05 EST 2003


Terry Reedy wrote:

> "Alex Martelli" <aleax at aleax.it> wrote in message
> news:%N8tb.28277$hV.1041253 at news2.tin.it...
>> to be consistent with your other arguments, no doubt you'd argue for
>> a .sort() followed by [-1] as "more general" than max...
> 
> By my definition of "more general", a function that returns all order
> statistics of a list is trivially more general than one that returns
> any fewer, including just one.  It conveys a superset of the

Of course.  So...?

> infomation conveyed by less general functions and answers a superset
> of the questions they answer.  If you add a control parameter
> specifying which order statistics to return, then less general
> functions have a restriced domain.
> 
> So I have no idea your intent in appearing to challenge this and how
> you think it contributes to your overall argument.  Is your idea of
> 'more general' so different?

Hmmm, nobody else seemed to have any problem understanding my quip,
including the poster at which it was directed.  Let me spell it out
for you: a few people are attacking 'sum' and defending 'reduce'
because the latter is "more general".  Why, so is sorting a sequence
"more general" than finding its maximum; for "consistency" with their
other arguments (which by this quip I'm alleging are no good) they
should then be clamoring for the removal of 'max' to leave only 'sort'.
(I did expect an O()-based objection and punctually got it, ready for
my repartee about reduce(str.add, lotsastrings) being O(N squared),
etc, etc).

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.


Alex





More information about the Python-list mailing list