map/filter/reduce/lambda opinions and background unscientificmini-survey

Peter Hansen peter at engcorp.com
Mon Jul 4 10:56:24 EDT 2005


Terry Hancock wrote:
> On Sunday 03 July 2005 07:05 pm, Erik Max Francis wrote:
>>I personally think that map looks clearer than a list comprehension for 
>>a simple function call

> This on the other hand,
>>	[str(x) for x in sequence]
> is practically plain English:
> 
> "call the function "str" on x, for every x in sequence"
> 
> Other than chopping out a few words, and using the () operator instead
> of "call", it's hard to imagine this being any closer to exactly what you
> would say to describe the operation. And for most of us, English comes
> easier than Computer Science jargon.

And with a better choice of names than "x", that line becomes even more 
self-documenting.

[str(parrot) for parrot in sequence], for example, tells you much more 
about what is going on than str(x) does.

Exactly what, I have no idea... but it says _so_ much more. ;-)

-Peter



More information about the Python-list mailing list