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


Groups > comp.lang.python > #95185

Re: Iterators membership testing

Newsgroups comp.lang.python
Date 2015-08-09 04:00 -0700
References <88256581-75d4-4f77-81f0-9e3e25baecbc@googlegroups.com> <mailman.2.1439112286.3627.python-list@python.org> <b1c0218c-05dd-402b-b2f0-5e0836146f76@googlegroups.com> <mailman.3.1439115197.3627.python-list@python.org>
Message-ID <09cb3411-be3b-4875-9042-af96c7f63504@googlegroups.com> (permalink)
Subject Re: Iterators membership testing
From Pierre Quentel <pierre.quentel@gmail.com>

Show all headers | View raw


> The trap you're seeing here is that iterating over an iterator always
> consumes it, but mentally, you're expecting this to be iterating over
> a new instance of the same sequence. 

No, I just tried to apply what I read in the docs :

1. I have y = A(10) which is an instance of a class which does not define __contains__ but does define __iter__

2. The value z = 0 is produced while iterating over y.

3. The sentence "x in y is true if some value z with x == z is produced while iterating over y" lead me to think that "0 in y" would be true.

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