Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93167

Re: converting boolean filter function to lambda

References <558C256D.7080903@stoneleaf.us>
Date 2015-06-26 09:59 +1000
Subject Re: converting boolean filter function to lambda
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.85.1435276743.3674.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Jun 26, 2015 at 1:59 AM, Ethan Furman <ethan@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: converting boolean filter function to lambda Chris Angelico <rosuav@gmail.com> - 2015-06-26 09:59 +1000

csiph-web