Python's simplicity philosophy
Terry Reedy
tjreedy at udel.edu
Fri Nov 14 17:31:00 EST 2003
"Alex Martelli" <aleax at aleax.it> wrote in message
news:8Y7tb.21901$9_.802189 at news1.tin.it...
> Dave Brueck wrote:
> ...
> >> results = [ func(x) for x in sequence ]
> >> ... instead of ...
> >> results = sequence.map(func) ??
> > Because I find the first much more readable>
> I entirely agree with both points.
For this pair, I like the second better. Different aesthetics.
> 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.
Here I might take the first. 'lambda' is something I feed 'stuck'
with.
Would the hypothetical
results = sequence.map(func x: x+23)
be any better?
How about a very hypothetical (post ``==repr deprecation)
results = sequence..map(`x+23`)
?
Terry J. Reedy
More information about the Python-list
mailing list