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


Groups > comp.lang.python > #95190

Re: Iterators membership testing

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 <python-python-list@m.gmane.org>
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 <breamoreboy@yahoo.co.uk>
Subject Re: Iterators membership testing
Date Sun, 9 Aug 2015 14:45:20 +0100
References <88256581-75d4-4f77-81f0-9e3e25baecbc@googlegroups.com> <CAPTjJmoibrvoxFt7o3XA+h_5ETTCS1b9uNUOhK=1UpRvo3PTpQ@mail.gmail.com> <20150809080917.2c87f22f@bigbox.christie.dr> <CAPTjJmo28ioMWiyqkR5B18M-0=oHyP3rx63EjCFCx13AZwNqSA@mail.gmail.com>
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 <CAPTjJmo28ioMWiyqkR5B18M-0=oHyP3rx63EjCFCx13AZwNqSA@mail.gmail.com>
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.8.1439127948.3627.python-list@python.org> (permalink)
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

Show key headers only | View raw


On 09/08/2015 14:11, Chris Angelico wrote:
> On Sun, Aug 9, 2015 at 11:09 PM, Tim Chase <tim@thechases.com> 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

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


Thread

Iterators membership testing Pierre Quentel <pierre.quentel@gmail.com> - 2015-08-09 02:06 -0700
  Re: Iterators membership testing Chris Angelico <rosuav@gmail.com> - 2015-08-09 19:24 +1000
    Re: Iterators membership testing Pierre Quentel <pierre.quentel@gmail.com> - 2015-08-09 02:55 -0700
      Re: Iterators membership testing Chris Angelico <rosuav@gmail.com> - 2015-08-09 20:13 +1000
        Re: Iterators membership testing Pierre Quentel <pierre.quentel@gmail.com> - 2015-08-09 04:00 -0700
          Re: Iterators membership testing Chris Angelico <rosuav@gmail.com> - 2015-08-09 21:10 +1000
      Re: Iterators membership testing Laura Creighton <lac@openend.se> - 2015-08-09 13:30 +0200
      Re: Iterators membership testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-09 14:49 +0100
  Re: Iterators membership testing Chris Angelico <rosuav@gmail.com> - 2015-08-09 23:11 +1000
  Re: Iterators membership testing Tim Chase <python.list@tim.thechases.com> - 2015-08-09 08:09 -0500
  Re: Iterators membership testing Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-08-09 14:45 +0100
  Re: Iterators membership testing Tim Chase <tim@thechases.com> - 2015-08-09 08:09 -0500

csiph-web