Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85430
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'class,': 0.07; 'function,': 0.09; 'grid': 0.09; 'iterate': 0.09; 'rows': 0.09; 'cc:addr:python-list': 0.11; 'charles': 0.16; 'factory': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterator': 0.16; 'iterator,': 0.16; 'objects.': 0.16; 'once.': 0.16; 'wrote:': 0.18; 'properly': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'apply.': 0.24; 'cc:2**0': 0.24; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'included': 0.31; 'formed': 0.31; 'once,': 0.31; 'class': 0.32; "i'd": 0.34; "can't": 0.35; 'something': 0.35; 'form.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'pm,': 0.38; 'rather': 0.38; 'new': 0.61; "you're": 0.61; 'back': 0.62; 'more': 0.64; 'brand': 0.72; '2015': 0.84; 'cycled': 0.84; 'subject:skip:S 10': 0.84; 'to:none': 0.92 |
| 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=Mw5rAT1Vk9UEvFcMezpmsnZVNNf7l0cKZHv1Rc1MuFk=; b=D0/yrxP8PcE2oxBVK4sIeaLFXIpeDNmE8qOxULoSmjtC8Q3QMazJUsgfClXjvJHOiQ iEKLaRLiwNrhk2llU/hWcPMAM7zMVu4lScS/fs52XiJWOiFWDOapF537A+/P0z9o3w0D Knm42sM6SI6IkbShl6IawUdGfELOVoButQb1vkZvdvoxTKkz5o5DK4LA5l51vLwjjyEb x+whkoDwftJbU4/sNOM3zzjucVbGYzijfMLrf9rAB+FtI/rB91WKSKGGEQ9MC8MDiLRz Fe6bAvXNxJg5lFv4hDXYHIFEFCbbODvx6iN/eDvQWD0z3JwegGiqebmOLZ4gKaigeHzm j2nQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.171.201 with SMTP id aw9mr21740843igc.2.1423550332997; Mon, 09 Feb 2015 22:38:52 -0800 (PST) |
| In-Reply-To | <54D9A22E.2070708@earthlink.net> |
| References | <mailman.18573.1423509383.18130.python-list@python.org> <54d94307$0$12998$c3e8da3$5496439d@news.astraweb.com> <CALwzidnufuFPX1K0QrAJZbEtS79xvOmhM7ZZ8t9dJSiKVvhUqQ@mail.gmail.com> <54D98A35.9060203@earthlink.net> <CAPTjJmrcbOYCuZCgiq9gStEG34nAvQ2gS-vZC-WUuAOPUV3hPw@mail.gmail.com> <54D9A22E.2070708@earthlink.net> |
| Date | Tue, 10 Feb 2015 17:38:52 +1100 |
| Subject | Re: __next__ and StopIteration |
| 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.15 |
| 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.18597.1423550718.18130.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1423550718 news.xs4all.nl 2867 [2001:888:2000:d::a6]:34166 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85430 |
Show key headers only | View raw
On Tue, Feb 10, 2015 at 5:16 PM, Charles Hixson <charleshixsn@earthlink.net> wrote: > Yes, rows and cols are lists, but I'm going to need to iterate through them > more than once. I'd rather do without a included class, but if a properly > formed iterator can only be cycled through once, and if I understand > properly that means I can't use the "class instance is it's own iterator" > form. When you write __iter__ as a generator function, what you actually have is a factory for iterator objects. (Generators are iterators.) When something calls __iter__ on your Grid, it gets back a brand new iterator which is independent of every other iterator from that or any other Grid, so you can iterate over the same Grid more than once. You're not writing __next__ here, so you're not using the class instance as its own iterator, which means that that consideration doesn't apply. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
__next__ and StopIteration Charles Hixson <charleshixsn@earthlink.net> - 2015-02-09 11:14 -0800
Re: __next__ and StopIteration Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-02-09 19:27 +0000
Re: __next__ and StopIteration Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-10 10:30 +1100
Re: __next__ and StopIteration Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-09 16:56 -0700
Re: __next__ and StopIteration Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-10 11:42 +1100
Re: __next__ and StopIteration Chris Angelico <rosuav@gmail.com> - 2015-02-10 11:54 +1100
Re: __next__ and StopIteration Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-10 12:11 +1100
Re: __next__ and StopIteration Chris Angelico <rosuav@gmail.com> - 2015-02-10 12:58 +1100
Re: __next__ and StopIteration Chris Kaynor <ckaynor@zindagigames.com> - 2015-02-09 16:59 -0800
Re: __next__ and StopIteration Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-10 16:54 +1100
Re: __next__ and StopIteration Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-10 01:30 -0700
Re: __next__ and StopIteration Chris Kaynor <ckaynor@zindagigames.com> - 2015-02-10 09:27 -0800
Re: __next__ and StopIteration Charles Hixson <charleshixsn@earthlink.net> - 2015-02-09 20:33 -0800
Re: __next__ and StopIteration Chris Angelico <rosuav@gmail.com> - 2015-02-10 15:46 +1100
Re: __next__ and StopIteration Charles Hixson <charleshixsn@earthlink.net> - 2015-02-09 22:16 -0800
Re: __next__ and StopIteration Chris Angelico <rosuav@gmail.com> - 2015-02-10 17:38 +1100
Re: __next__ and StopIteration Ethan Furman <ethan@stoneleaf.us> - 2015-02-10 08:44 -0800
Re: __next__ and StopIteration Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-10 09:53 -0700
Re: __next__ and StopIteration Ethan Furman <ethan@stoneleaf.us> - 2015-02-10 09:33 -0800
csiph-web