converting boolean filter function to lambda

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Jun 25 20:09:18 EDT 2015


On 26/06/2015 00:59, Chris Angelico wrote:
> 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
>

In exactly the same way that swooping-in cape-wearing Greg Ewing, from 
the home of 10 man rugby, had to point out to Ethan some years back what 
"booted into touch" meant? :)

I've also seen Ethan refer to bowlers today, I just hope he's very 
careful and doesn't get caught on the back foot.  Next question from 
Ethan is?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list