Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85416
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'broken': 0.04; 'allowed.': 0.07; 'method.': 0.07; 'suddenly': 0.07; 'subtle': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; '11:42': 0.16; 'forbid': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterator': 0.16; 'iterators': 0.16; 'nans': 0.16; 'track.': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'documented': 0.24; 'lets': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'skip:_ 10': 0.34; 'maybe': 0.34; 'received:209.85': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'received:209': 0.37; 'being': 0.38; 'problems': 0.38; 'expect': 0.39; 'even': 0.60; 'skip:* 10': 0.61; "you'll": 0.62; 'such': 0.63; 'series': 0.66; '2015': 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=zBhg0L0H3G2O4hwofqVbMrZvOBFh68zWEwihkZq6d+g=; b=qDzj5j3IUydyl6c7LXukeQR557UMCOhKQTzKr1rOPIFTBNR1GL5II+GbR4GHINZjJn +/vhJeD6meA9UA6FFlEH4Y047F0C88l9QMMnDgTTyUer2aBiphcmsUlUrVFpXAwKY64i SDMEgQ5RYHzJ4tzKF02Tia+xI+gSvdkJIrsTr0bYF9z74/FsLfPjP1JJFXB+f/GrefNW F/PRzRBNgMXZbR0fD5Wqh1QmS/7KphTBy0UaPWl3bCqzTheZA4P6SrqWi3rGgDmSnbfY bYEapMR9M9y0HPuyACz2v4YAOGRNITbGjo+DJjlobCVr9f310bZ+SXn034A9Hk1i871p ngeQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.200.136 with SMTP id ew8mr27710202icb.59.1423529662157; Mon, 09 Feb 2015 16:54:22 -0800 (PST) |
| In-Reply-To | <54d9540d$0$13003$c3e8da3$5496439d@news.astraweb.com> |
| References | <mailman.18573.1423509383.18130.python-list@python.org> <54d94307$0$12998$c3e8da3$5496439d@news.astraweb.com> <mailman.18582.1423526240.18130.python-list@python.org> <54d9540d$0$13003$c3e8da3$5496439d@news.astraweb.com> |
| Date | Tue, 10 Feb 2015 11:54:22 +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.18585.1423529677.18130.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1423529677 news.xs4all.nl 2910 [2001:888:2000:d::a6]:47785 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85416 |
Show key headers only | View raw
On Tue, Feb 10, 2015 at 11:42 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > Also, *technically* iterators may be re-iterable. The docs say that > iterators which fail to raise StopIteration forever once they are exhausted > are "broken", but the docs do not forbid broken iterators. Consenting > adults and all that. You might want an iterator with a reset() method. Even > an outright broken iterator! > > def __next__(self): > if random.random() < 0.1: raise StopIteration > return random.random() > > Why you would want one, I don't know, but if you have a hankering for such a > beast, Python lets you do it. Yes, it is allowed. But when you write code that's documented as being "broken", you should expect annoying, subtle errors, maybe a long way down the track. You know all those niggling problems you get when you find some NaNs in a series of numbers, and suddenly things don't sort stably and such? You'll hanker for those well-defined days. :) 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