Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106226
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Strange range |
| Date | Sat, 2 Apr 2016 01:31:20 +1100 |
| Lines | 25 |
| Message-ID | <mailman.311.1459521083.28225.python-list@python.org> (permalink) |
| References | <87y48xjwqq.fsf@elektro.pacujo.net> <56fe76f2$0$22141$c3e8da3$5496439d@news.astraweb.com> <ndlvrt$1hlp$1@gioia.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de S9fyUqPofCmGU/6x+3kfBAcFpbz8fKw5XL6iFI1so9Hw== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.018 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'example:': 0.10; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterator': 0.16; 'iterator.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'scratch': 0.16; 'sequence.': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'object.': 0.22; 'am,': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'implicitly': 0.29; "d'aprano": 0.33; 'steven': 0.33; 'received:google.com': 0.35; 'done': 0.35; 'step': 0.36; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'starting': 0.37; 'received:209': 0.38; 'why': 0.39; 'does': 0.39; "'for'": 0.84; 'again?': 0.84; 'chrisa': 0.84; 'to:none': 0.91 |
| 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; bh=dnwphNHidT8WyU+rVUvOcAE6EtbX2Uw1K5McEfz3i94=; b=DhuGtOS2oTMdHKCXQwjko7yvCBKyFSETJx8FIMGyBxfrKP3Dseks94y+BXXy89KxGn VXjyhJNQ/mf24zBVLdCNd4TzcykIGr8J1DzHyCSXLq1xkSQp+BYSEmv4AizuYFMPlYjL Jy+wY4lmQfg9O1+ayTfkCOQXCLdOdvoT1lHmNfF/VFAXRw9C2+g8gyn766QBJvZ4b6bV pi5910+uCX/cbV3hkV54ovJ97IFSZqtq0nFDfRWJ/RQNJDBb2MxaGcRiF6GRj5XpyOWa TL32WI195MJ7fjHbpON43atyZTgLU5KHOLeeHof4i02j8fWtbuyY+fPu+H3xVFjaV+Fv fQAw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=dnwphNHidT8WyU+rVUvOcAE6EtbX2Uw1K5McEfz3i94=; b=VXweNtygUeUHCfe0ZAaMGHJIdmK4chOjuy2IwtUNomJpFGBCkAtDOPGXJcq7tlf/km 3ECQj7AGhzVWM6kx2zTj4aNhfUrOuStMIq7PHwQzNI3h+rCz2ig5cqKQ7sWq2B/ewb/0 qMstL1nDpxLkz+9rZHBNi79MMeb7G+lA+7l41JgJZw+nXQ3nGt68zIOIYC5jZopGwgZY kgpwMahCPhUZC0Sho0joCI1FSOaTXoOw5+JBsNI5bJMNwcvIlG1hz35Y2FIeLcquFuR9 DCdZPaCCyuDnhlG8pADX9oQgb5u+6Ueo/OhBSEhKR2P9Hei0lhaaJSsxRDoqWO11ZPWm Q5oA== |
| X-Gm-Message-State | AD7BkJIGZpWMDzFMeoaFRQICv3X5QzjQrpzITuBb14rUXxlxAnh8+1aSvSGJMj+IFcTcQzT7bz95ZDmZQ3yy5w== |
| X-Received | by 10.50.112.169 with SMTP id ir9mr3897578igb.92.1459521080359; Fri, 01 Apr 2016 07:31:20 -0700 (PDT) |
| In-Reply-To | <ndlvrt$1hlp$1@gioia.aioe.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| 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> |
| Xref | csiph.com comp.lang.python:106226 |
Show key headers only | View raw
On Sat, Apr 2, 2016 at 1:16 AM, Fabien <fabien.maussion@gmail.com> wrote: > On 04/01/2016 03:26 PM, Steven D'Aprano wrote: >> >> Incorrect. range is a lazy sequence. > > > But how does range "know" that it has to start from scratch again? As in > this example: > > it = range(10) > for i in it: > if i >= 3: > break > for i in it: > # why does it start from zero again? > print(i) It's not an iterator. It's an iterable. So every time you call iter() on it - which is done implicitly by the starting of the 'for' loop - you get a completely new iterator which will step through the whole range object. *A range object is not an iterator.* ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-01 16:15 +0300
Re: Strange range Chris Angelico <rosuav@gmail.com> - 2016-04-02 00:24 +1100
Re: Strange range Steven D'Aprano <steve@pearwood.info> - 2016-04-02 00:26 +1100
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-01 17:12 +0300
Re: Strange range Random832 <random832@fastmail.com> - 2016-04-01 10:39 -0400
Re: Strange range Fabien <fabien.maussion@gmail.com> - 2016-04-01 16:16 +0200
Re: Strange range Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-04-01 17:28 +0300
Re: Strange range Chris Angelico <rosuav@gmail.com> - 2016-04-02 01:31 +1100
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-01 17:34 +0300
Re: Strange range Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-04-01 17:44 +0300
Re: Strange range Chris Angelico <rosuav@gmail.com> - 2016-04-02 01:45 +1100
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-01 18:43 +0300
Re: Strange range Erik <python@lucidity.plus.com> - 2016-04-01 20:58 +0100
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-01 23:14 +0300
Re: Strange range Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-01 20:21 +0000
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-01 23:44 +0300
Re: Strange range Steven D'Aprano <steve@pearwood.info> - 2016-04-02 21:09 +1100
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-02 13:48 +0300
Re: Strange range Ned Batchelder <ned@nedbatchelder.com> - 2016-04-02 12:47 -0700
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-02 23:44 +0300
Re: Strange range Chris Angelico <rosuav@gmail.com> - 2016-04-03 07:05 +1000
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-03 00:40 +0300
Re: Strange range Ned Batchelder <ned@nedbatchelder.com> - 2016-04-02 14:50 -0700
Re: Strange range Stephen Hansen <me+python@ixokai.io> - 2016-04-02 23:43 -0700
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-03 09:58 +0300
Re: Strange range Chris Angelico <rosuav@gmail.com> - 2016-04-03 17:10 +1000
Re: Strange range Ethan Furman <ethan@stoneleaf.us> - 2016-04-03 09:28 -0700
Re: Strange range Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-04-04 13:21 +0100
Re: Strange range Chris Angelico <rosuav@gmail.com> - 2016-04-03 17:08 +1000
Re: Strange range Steven D'Aprano <steve@pearwood.info> - 2016-04-03 14:43 +1000
Re: Strange range Random832 <random832@fastmail.com> - 2016-04-03 01:20 -0400
Re: Strange range Steven D'Aprano <steve@pearwood.info> - 2016-04-03 15:28 +1000
Re: Strange range Marko Rauhamaa <marko@pacujo.net> - 2016-04-01 17:32 +0300
Re: Strange range Random832 <random832@fastmail.com> - 2016-04-01 10:42 -0400
Re: Strange range Chris Angelico <rosuav@gmail.com> - 2016-04-02 01:50 +1100
Re: Strange range Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-01 08:52 -0600
csiph-web