Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88391
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.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.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'explicitly': 0.05; 'rename': 0.07; 'next,': 0.09; 'noted,': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'def': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'intended.': 0.16; 'renaming': 0.16; 'subclass': 0.16; 'subject:generator': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'written': 0.21; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'subject:/': 0.26; '2010,': 0.27; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; '"",': 0.31; '>>>>': 0.31; 'object.': 0.31; 'file': 0.32; 'class': 0.32; 'probably': 0.32; 'run': 0.32; '(most': 0.33; 'skip:_ 10': 0.34; 'received:google.com': 0.35; 'method': 0.36; 'skip:- 20': 0.37; 'recent': 0.39; 'break': 0.61; 'more': 0.64; 'note:': 0.66; '2015': 0.84; 'albert': 0.91; '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=qvmq2QgMfPMXaJftGDNCFlZ/Uea7b4D8QLzDtOmmLLg=; b=HJ5GrLBUPdHbzLjjy6bp1G+hD0Tw7mqVea3Or2HHHteVKtUh4TvMTv3+0xT/6zMuum hcdyxlVzxzZFBnekrpHag60WWXlSFvB/AwECtHal5e3DYV5R9XWUb9QEKij85JgIfLlA 8aViVYiU/nW/CspqF196UXcNDyi8Ei1XAsKrO4NSqf8U8PgeJFIal9jVP7vYHdkjBVTr 9zLjFG0nn/MG9vmHGyw3o4y6apBL/0D4LpDl/OFRQx3PPBdH5qyHpWFb/hGqjO+FITMp FqeSMPG06gVjgnv2rVG1myhO9+MqGE4Bsyn8+4dNW2YYuu7uQFQQBCXl38wZ1lVIQ06L UpUw== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.29.109 with SMTP id j13mr5254600igh.2.1427816210883; Tue, 31 Mar 2015 08:36:50 -0700 (PDT) |
| In-Reply-To | <551ab739$0$3042$e4fe514c@dreader35.news.xs4all.nl> |
| References | <ff0bc8eb-63e4-40ea-8d31-301625a3d470@googlegroups.com> <55062bda$0$12998$c3e8da3$5496439d@news.astraweb.com> <551a9ebe$0$2987$e4fe514c@dreader35.news.xs4all.nl> <mailman.372.1427809109.10327.python-list@python.org> <551ab739$0$3042$e4fe514c@dreader35.news.xs4all.nl> |
| Date | Wed, 1 Apr 2015 02:36:50 +1100 |
| Subject | Re: generator/coroutine terminology |
| 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.19 |
| 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.378.1427816214.10327.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1427816214 news.xs4all.nl 2962 [2001:888:2000:d::a6]:53834 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:88391 |
Show key headers only | View raw
On Wed, Apr 1, 2015 at 2:03 AM, Albert van der Horst <albert@spenarnc.xs4all.nl> wrote: > class Squares: > def __init__(self): > self.i = 0 > def __next__(self): > self.i += 1 > return self.i**2 > def __iter__(self): > return self > > albert@cherry:/tmp$ python > Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> from aap import * >>>> for i in Squares(): > ... print i > ... if i>50: break > ... > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: instance has no next() method >>>> > > / -------------------------- > > Probably not what is intended. > > Last minute note: > renaming __next__() into next() did the job. That class was written for Python 3, not Python 2. In Py2, you need to rename __next__ to next, as you noted, and you probably also want to explicitly subclass object. Or just run it under Python 3. :) ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: generator/coroutine terminology albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-03-31 13:18 +0000
Re: generator/coroutine terminology Dave Angel <davea@davea.name> - 2015-03-31 09:38 -0400
Re: generator/coroutine terminology albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-03-31 15:03 +0000
Re: generator/coroutine terminology Chris Angelico <rosuav@gmail.com> - 2015-04-01 02:36 +1100
Re: generator/coroutine terminology Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-04-03 17:02 +1100
Re: generator/coroutine terminology albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-04-18 17:52 +0000
Re: generator/coroutine terminology Paul Rubin <no.email@nospam.invalid> - 2015-04-02 23:46 -0700
csiph-web