List comprehension confusion...

Peter Hansen peter at engcorp.com
Sun Feb 2 01:03:19 EST 2003


Lulu of the Lotus-Eaters wrote:
> 
> Andrew Dalke <adalke at mindspring.com> wrote previously:
> |get the "some_field" attribute of all elements in a list
> |results = [term.some_field for term in data]
> 
> Just to throw flame on the fire, I am one of the odd people who find map
> quite readable too:
> 
>   result = map(lambda t: t.some_field, data)

I find map very readable as well... but not lambdas.  :-)




More information about the Python-list mailing list