Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8288

Re: writable iterators?

Message-Id <1536878.qVoOGUtdWV@PointedEars.de>
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-06-23 12:23 +0200
Subject Re: writable iterators?
Newsgroups comp.lang.python
References <mailman.296.1308770918.1164.python-list@python.org> <4e026497$0$29975$c3e8da3$5496439d@news.astraweb.com> <ittokg$r6n$1@speranza.aioe.org> <2372171.ArG6xLiZAS@PointedEars.de> <4e029c8d$0$29965$c3e8da3$5496439d@news.astraweb.com>
Followup-To comp.lang.python

Followups directed to: comp.lang.python

Show all headers | View raw


[Sorry for over-quoting, I am not sure how to trim this properly]

Steven D'Aprano wrote:

> 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.
>> 
>> <http://docs.python.org/reference/simple_stmts.html#the-yield-statement>
>> 
>> 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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

writable iterators? Neal Becker <ndbecker2@gmail.com> - 2011-06-22 15:28 -0400
  Re: writable iterators? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-22 21:54 +0000
    Re: writable iterators? Mel <mwilson@the-wire.com> - 2011-06-22 17:59 -0400
      Re: writable iterators? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-23 01:30 +0200
        Re: writable iterators? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-23 11:53 +1000
          Re: writable iterators? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-23 12:23 +0200
    Re: writable iterators? Neal Becker <ndbecker2@gmail.com> - 2011-06-22 19:10 -0400
      Re: writable iterators? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-23 11:50 +1000
    Re: writable iterators? MRAB <python@mrabarnett.plus.com> - 2011-06-23 01:34 +0100
    Re: writable iterators? Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-23 09:02 -0600
    Re: writable iterators? Neal Becker <ndbecker2@gmail.com> - 2011-06-23 12:06 -0400
  Re: writable iterators? Chris Torek <nospam@torek.net> - 2011-06-23 18:26 +0000
    Re: writable iterators? Chris Torek <nospam@torek.net> - 2011-06-23 22:17 +0000
      Re: writable iterators? Neal Becker <ndbecker2@gmail.com> - 2011-06-23 21:10 -0400

csiph-web