catching exceptions in expressions
Terry Reedy
tjreedy at udel.edu
Thu Aug 7 18:55:27 EDT 2003
"Andrew Dalke" <adalke at mindspring.com> wrote in message
news:bgua9j$oll$1 at slb4.atl.mindspring.net...
> When list comprehensions came out, one of the things I found
> I liked about it was it replaced a lot of code like
>
> new_data = []
> for x in data:
> new_data.append(x.attr)
> data = new_data
Isn't this the same as
data = map(lambda d: d.attr, data)
?
> I tried to abstract that into a function, like
>
> def get_list_attr(data, attrname):
> new_data = []
> ...
>
> but could never come up with a good name for that function.
mapattr?
Terry J. Reedy
More information about the Python-list
mailing list