Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Erik Newsgroups: comp.lang.python Subject: Re: Strange range Date: Fri, 1 Apr 2016 20:58:33 +0100 Lines: 30 Message-ID: References: <87y48xjwqq.fsf@elektro.pacujo.net> <56fe76f2$0$22141$c3e8da3$5496439d@news.astraweb.com> <87lh4xjt37.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de TpbfODlU2U3okYxTDRv43A6GAJCQ8W0qELczSv5y11Uw== Return-Path: 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; 'method,': 0.07; 'from:addr:python': 0.16; 'hypothetical': 0.16; 'iterating': 0.16; 'iterators': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'odd': 0.18; '>>>': 0.20; 'to:2**1': 0.21; '(where': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; "doesn't": 0.26; 'chris': 0.26; 'sequence': 0.27; 'class': 0.33; 'replace': 0.35; 'level': 0.35; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'expect': 0.37; 'seem': 0.37; 'or,': 0.38; 'why': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=Rr04V3SK c=1 sm=1 tr=0 a=d6bQx1Csmutac+MnUcj9pQ==:117 a=d6bQx1Csmutac+MnUcj9pQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=N659UExz7-8A:10 a=pGLkceISAAAA:8 a=iF3y2F7_EnlPl9MyRrMA:9 a=pILNOxqGKmIA:10 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <87lh4xjt37.fsf@elektro.pacujo.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:106251 On 01/04/16 15:34, Marko Rauhamaa wrote: > Chris Angelico : > >> *A range object is not an iterator.* > > We now have learned as much. > > However, doesn't that extra level of indirection seem like an odd > choice? If you write your own class which has an __iter__ method, would you expect: >>> o = MyClass() >>> i1 = iter(o) >>> i2 = iter(o) >>> list(i1) ['foo', 'bar', 'baz'] >>> list(i2) [] ? Or, would you expect both iterators to be independent and both return the 'foo', 'bar', 'baz' sequence (where that is the hypothetical result of iterating over your object)? If you now replace MyClass() with range(10), why would you expect the two iterators to be related? E.