Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'nicely': 0.07; 'val': 0.07; 'obj': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.13; 'interpreter': 0.15; '11:09': 0.16; 'iterator': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.16; 'runs': 0.18; 'language': 0.19; '>>>': 0.20; '2015': 0.20; 'aug': 0.20; 'lawrence': 0.22; 'this:': 0.23; 'tim': 0.24; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'sense': 0.26; 'chris': 0.26; 'right.': 0.27; 'chase': 0.29; "i'm": 0.30; 'probably': 0.31; 'another': 0.32; 'language.': 0.32; 'handle': 0.34; 'false': 0.35; 'something': 0.35; 'step': 0.36; 'depends': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; "won't": 0.38; 'sure': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'charset:windows-1252': 0.62; 'our': 0.64; 'chrisa': 0.84; "it'd": 0.84; 'pythonistas,': 0.84; 'readers.': 0.84; 'url:photos': 0.84; 'subject:membership': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Iterators membership testing Date: Sun, 9 Aug 2015 14:45:20 +0100 References: <88256581-75d4-4f77-81f0-9e3e25baecbc@googlegroups.com> <20150809080917.2c87f22f@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-146-0-160.as13285.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439127948 news.xs4all.nl 2821 [2001:888:2000:d::a6]:46680 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 4121 X-Received-Body-CRC: 1414503727 Xref: csiph.com comp.lang.python:95190 On 09/08/2015 14:11, Chris Angelico wrote: > On Sun, Aug 9, 2015 at 11:09 PM, Tim Chase wrote: >> On 2015-08-09 19:24, Chris Angelico wrote: >>> That's exactly right. The only way for the interpreter to handle >>> 'in' on an iterator is something like this: >>> >>> def contains(iter, obj): >>> for val in iter: >>> if val == obj: return True >>> return False >> >> Which can nicely be written as >> >> any(i == obj for obj in iter) > > Indeed it can, although I'm not sure whether it'd just have been > another step in the explanation :) Whether or not that makes perfect > sense depends on the reader. > > ChrisA > This one probably won't make make sense to most readers. any("Australian batsmen scored any() runs recently?") See also http://www.cricketcountry.com/photos/photo-england-supporters-sell-hardly-used-australian-bats-314378 :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence