Guido's regrets: filter and map

Terry Reedy tjreedy at udel.edu
Sat Nov 23 20:35:50 EST 2002


"Simon Burton" <simonb at webone.com.au> wrote in message
news:pan.2002.11.24.01.35.22.907943 at webone.com.au...
> Hello,
>
> I just read Guido's "python regret's" slide's from OSCON,
>
http://www.google.com/search?hl=en&ie=ISO-8859-1&q=OSCON+%22python+reg
rets%22
> and one thing i can't work out is,
> he is saying we can do map() and filter() with
> list comprehensions (it's faster too)
> eg.
>
> amapedlist = [ somefunc(x) for x in alist ]
>
> But how would we do a filter with list comprehensions?

filteredlist = [item for item in alist if condition]

TJR





More information about the Python-list mailing list