Python's simplicity philosophy
aleax at aleax.it
Fri Nov 14 18:06:12 CET 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 ]
results = sequence.map(lambda x: x+23)
where using the HOF approach forces you to understand (and read) lambda too.
More information about the Python-list