Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-Id: <1536878.qVoOGUtdWV@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Thu, 23 Jun 2011 12:23:35 +0200 User-Agent: KNode/4.4.7 Content-Transfer-Encoding: 7Bit Subject: Re: writable iterators? Newsgroups: comp.lang.python References: <4e026497$0$29975$c3e8da3$5496439d@news.astraweb.com> <2372171.ArG6xLiZAS@PointedEars.de> <4e029c8d$0$29965$c3e8da3$5496439d@news.astraweb.com> Followup-To: comp.lang.python MIME-Version: 1.0 Lines: 44 NNTP-Posting-Date: 23 Jun 2011 12:23:35 CEST NNTP-Posting-Host: ef47c9ae.newsspool1.arcor-online.net X-Trace: DXC=VQJh`CF2EOi016@cHD@m;jic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgb9oB1OC=45TlDZm8W4\YJNlT<8F<]0D<`ikN; On Thu, 23 Jun 2011 09:30 am Thomas 'PointedEars' Lahn wrote: >> Mel wrote: >>> Steven D'Aprano wrote: >>>> I *guess* that what you mean by "writable iterators" is that rebinding >>>> e should change seq in place, i.e. you would expect that seq should now >>>> equal [42, 42]. Is that what you mean? It's not clear. >>>> >>>> Fortunately, that's not how it works, and far from being a >>>> "limitation", it would be *disastrous* if iterables worked that way. I >>>> can't imagine how many bugs would occur from people reassigning to the >>>> loop variable, forgetting that it had a side-effect of also reassigning >>>> to the iterable. Fortunately, Python is not that badly designed. >>> >>> And for an iterator like >>> >>> def things(): >>> yield 1 >>> yield 11 >>> yield 4 >>> yield 9 >>> >>> I don't know what it could even mean. >> >> >> >> You could have tried to debug. > > I think you have missed the point of Mel's comment. He knows what the > yield statement does. He doesn't know what it would mean to "write to" an > iterator like things(). > > Neither do I. AIUI the OP is referring to write accesses to the iteration variable (for want of a better term), not being aware what iterators are. -- PointedEars Bitte keine Kopien per E-Mail. / Please do not Cc: me.