Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'python': 0.08; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'readable': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'wrote:': 0.14; 'blah': 0.16; 'iterator': 0.16; 'iterators,': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'cc:addr:python-list': 0.17; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'loop,': 0.23; 'works.': 0.23; 'subject:?': 0.29; 'cc:addr:python.org': 0.30; 'header:User-Agent:1': 0.35; 'something': 0.37; 'change': 0.37; 'limitation': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'list,': 0.39; 'believe': 0.66; 'received:websitewelcome.com': 0.67; 'concept': 0.73; "'e'": 0.84; 'received:gateway15.websitewelcome.com': 0.84; 'sequence:': 0.84 Date: Wed, 22 Jun 2011 13:04:40 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Neal Becker Subject: Re: writable iterators? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:1982 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308772188 news.xs4all.nl 14139 [::ffff:82.94.164.166]:46234 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8242 Neal Becker wrote: > AFAICT, the python iterator concept only supports readable iterators, not write. > Is this true? > > for example: > > for e in sequence: > do something that reads e > e = blah # will do nothing > > I believe this is not a limitation on the for loop, but a limitation on the > python iterator concept. Is this correct? No. e = blah will rebind the indentifier 'e' with 'blah' whatever that is. That is how python works. Now, if e is mutable, say a list, you can do e.append(blah) and, since the name 'e' is not being rebound, you would see the change in 'sequence'. ~Ethan~