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


Groups > comp.lang.python > #93167

Re: converting boolean filter function to lambda

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.91.MISMATCH!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.102
X-Spam-Level *
X-Spam-Evidence '*H*': 0.81; '*S*': 0.02; 'cc:addr:python-list': 0.10; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'am,': 0.23; '2015': 0.23; 'header:In- Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.28; 'looks': 0.29; 'function': 0.30; "skip:' 10": 0.30; 'fri,': 0.31; 'skip:[ 10': 0.32; 'received:google.com': 0.34; 'done': 0.35; 'attempt': 0.35; 'besides': 0.35; 'list': 0.35; 'subject:: ': 0.37; '26,': 0.72; 'chrisa': 0.84; 'to:none': 0.90; 'ethan': 0.91; 'furman': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=J5g1/1488T6vxqHoUjypJKNSiOibYVktSGBulTv64K0=; b=0lMxTFRatvCHDdCEN4dxwvz1n209ILfP0rOUia8tUbTmWzm8/jekf2GyM+HK/OTKaU xXaLescPqfEQiYRl15IYloIMDRJvE0CA0oMkusOC2om6Ry22MYtb+Ry9FkPUf5uYRJsB 3ysXxrd2yvz7tYuphvfeqt8hrSPT4aWdACqanl6BxMbbn7prBexjIpuxh1r92606wDla qfQtuvL59ynBnXmloBmxKkibw62qtcDK5g2cbHnkn38poHd7+2vtzTcyExbaqAU/KdlP wb//JfySjKi5JxPmiWLtE0XcLv0VuhaJp6ctrHMfoKdCLnnx2hlNSdaQV292zpYhahVN pfkA==
MIME-Version 1.0
X-Received by 10.107.160.141 with SMTP id j135mr64162217ioe.43.1435276741045; Thu, 25 Jun 2015 16:59:01 -0700 (PDT)
In-Reply-To <558C256D.7080903@stoneleaf.us>
References <558C256D.7080903@stoneleaf.us>
Date Fri, 26 Jun 2015 09:59:00 +1000
Subject Re: converting boolean filter function to lambda
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.85.1435276743.3674.python-list@python.org> (permalink)
Lines 13
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1435276743 news.xs4all.nl 2880 [2001:888:2000:d::a6]:45606
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:93167

Show key headers only | 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