Python's simplicity philosophy

Alex Martelli aleax at aleax.it
Fri Nov 14 12:06:12 EST 2003


Dave Brueck wrote:
   ...
>> Why, pray-tell, would you want an OO program to do:
>>
>> results = [ func(x) for x in sequence ]
>>
>> ... instead of ...
>>
>> results = sequence.map(func) ??
> 
> Because I find the first much more readable (and IMO the "an OO program to
> do" bit is irrelevent from a practical point of view).

I entirely agree with both points.  They're even clearer when the
contrast is between, e.g.:

results = [ x+23 for x in sequence ]

and:

results = sequence.map(lambda x: x+23)

where using the HOF approach forces you to understand (and read) lambda too.


Alex





More information about the Python-list mailing list