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


Groups > comp.lang.python > #93167 > unrolled thread

Re: converting boolean filter function to lambda

Started byChris Angelico <rosuav@gmail.com>
First post2015-06-26 09:59 +1000
Last post2015-06-26 09:59 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#93167 — Re: converting boolean filter function to lambda

FromChris Angelico <rosuav@gmail.com>
Date2015-06-26 09:59 +1000
SubjectRe: converting boolean filter function to lambda
Message-ID<mailman.85.1435276743.3674.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web