Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.065 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'lambda': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.16; 'language': 0.19; 'greg': 0.22; 'lawrence': 0.22; 'am,': 0.23; '2015': 0.23; "i've": 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'question': 0.26; 'header:X -Complaints-To:1': 0.26; 'chris': 0.26; "doesn't": 0.28; 'looks': 0.29; 'function': 0.30; "skip:' 10": 0.30; 'fri,': 0.31; 'skip:[ 10': 0.32; 'language.': 0.32; 'point': 0.33; "he's": 0.33; 'is?': 0.33; 'to:addr:python-list': 0.35; 'next': 0.35; 'done': 0.35; 'attempt': 0.35; 'besides': 0.35; 'list': 0.35; 'subject:: ': 0.37; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'mark': 0.40; 'some': 0.40; 'back': 0.61; 'hope': 0.61; 'today,': 0.62; 'our': 0.64; 'charset:windows-1252': 0.65; 'home': 0.67; '26,': 0.72; 'chrisa': 0.84; 'pythonistas,': 0.84; 'careful': 0.91; 'ethan': 0.91; 'furman': 0.91; 'received:2': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: converting boolean filter function to lambda Date: Fri, 26 Jun 2015 01:09:18 +0100 References: <558C256D.7080903@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-98-197-151.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435277372 news.xs4all.nl 2889 [2001:888:2000:d::a6]:48417 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93168 On 26/06/2015 00:59, Chris Angelico wrote: > On Fri, Jun 26, 2015 at 1:59 AM, Ethan Furman 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