Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'loop.': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'cc:addr:python-list': 0.10; 'python': 0.11; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'iterating': 0.16; 'message-id:@fido.openend.se': 0.16; 'mylist': 0.16; 'received:89.233': 0.16; 'received:89.233.217': 0.16; 'received:89.233.217.133': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'laura': 0.18; '>>>': 0.20; 'cc:addr:python.org': 0.21; 'cc:2**1': 0.22; 'header:In-Reply- To:1': 0.24; '[2]': 0.27; 'subject:/': 0.29; 'received:se': 0.29; 'cc:no real name:2**1': 0.29; 'print': 0.31; 'problem': 0.33; 'lists': 0.34; 'lists.': 0.35; 'subject:: ': 0.37; 'charset:us- ascii': 0.37; 'end': 0.39; 'things': 0.39; 'expect': 0.39; 'real': 0.61; 'header:Message-Id:1': 0.62; 'more': 0.62; 'mar': 0.65; 'received:89': 0.80; 'subject:good': 0.84 To: Fabien cc: python-list@python.org, lac@openend.se From: Laura Creighton Subject: Re: zip as iterator and bad/good practices In-Reply-To: Message from Fabien of "Fri, 12 Jun 2015 17:00:09 +0200." References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25585.1434141274.1@fido> Date: Fri, 12 Jun 2015 22:34:34 +0200 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [89.233.217.130]); Fri, 12 Jun 2015 22:34:35 +0200 (CEST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1434141281 news.xs4all.nl 2960 [2001:888:2000:d::a6]:56729 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92552 The real problem is removing things from lists when you are iterating over them, not adding things to the end of lists. Python 2.7.9 (default, Mar 1 2015, 12:57:24) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> mylist = [1,2,3] >>> for i in mylist: ... print i ... mylist.remove(i) ... 1 3 >>> mylist [2] Most people expect 1 2 and 3 to get printed, and mylist to be empty at the end of this loop. Laura