converting boolean filter function to lambda
Chris Angelico
rosuav at gmail.com
Thu Jun 25 19:59:00 EDT 2015
On Fri, Jun 26, 2015 at 1:59 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> My attempt at a lambda function fails:
>
> filter(lambda p: (p in c for c in contacts), main)
> # ['291.792.9001', '291.792.9000']
>
> Besides using a lambda ;) , what have I done wrong?
This looks like a job for a list comprehension!
(Cue the swooping-in cape-wearing list comp, coming to save the day)
ChrisA
More information about the Python-list
mailing list