Securing a future for anonymous functions in Python

Jeff Shannon jeff at ccvcorp.com
Mon Jan 10 12:53:13 EST 2005


Jacek Generowicz wrote:
> "Anna" <annaraven at gmail.com> writes:
>
>>But first, wouldn't something like:
>>
>>[x+1 for x in seq]
>>
>>be even clearer?
> 
> I'm glad you mentioned that. [...]
> 
> As to whether it is clearer. That depends. I would venture to suggest
> that, given a pool of laboratory rats with no previous exposure to
> Python, more of them would understand the map-lambda than the list
> comprehension. 

I would venture to suggest the exact opposite, that the syntax of a 
list comprehension is in itself suggestive of its meaning, while 'map' 
and 'lambda' are opaque until you've researched them.  The verb 'to 
map', in this mathematical sense, is not part of standard usage among 
anyone that *I* know.  Instead, they'd speak of doing something for 
(or to) each item in a group -- exactly what list comps express.

Speaking for *this* laboratory rat, at least, map/lambda was always a 
nasty puzzle for me and difficult to sort out.  But when list comps 
were introduced, after reading just a sentence or two on how they 
worked, they were completely clear and understandable -- much more so 
than map/lambda after many months of exposure.

Jeff Shannon
Technician/Programmer
Credit International




More information about the Python-list mailing list