Guido's regrets: filter and map

Wojtek Walczak gminick at hacker.pl
Sun Nov 24 03:08:20 EST 2002


Dnia Sun, 24 Nov 2002 12:35:23 +1100, Simon Burton napisał(a):
> amapedlist = [ somefunc(x) for x in alist ]
> But how would we do a filter with list comprehensions?
You can put an 'if' statement after 'alist' list in your example.
E.g: amapedlist = [ somefunc(x) for x in alist if x > 10]

-- 
[ ] gminick (at) underground.org.pl  http://gminick.linuxsecurity.pl/ [ ]
[ "Po prostu lubie poranna samotnosc, bo wtedy kawa smakuje najlepiej." ]



More information about the Python-list mailing list