Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'modify': 0.07; 'clean.': 0.09; 'iterate': 0.09; 'mailscanner,': 0.16; 'silly': 0.16; 'modification': 0.16; 'code.': 0.18; 'header:User-Agent:1': 0.23; 'case.': 0.24; 'header:In-Reply-To:1': 0.27; 'scanned': 0.29; 'another': 0.32; 'something': 0.35; 'there': 0.35; 'believed': 0.36; 'received:192.168.2': 0.37; 'list': 0.37; 'to:addr:python- list': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'called': 0.40; 'dangerous': 0.60; 'viruses': 0.61; 'name:': 0.61; 'within': 0.65 Date: Mon, 13 Jan 2014 10:00:46 +0100 From: Laszlo Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: L[:] References: <1389375507.21198.YahooMailBasic@web163801.mail.gq1.yahoo.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-shopzeus-MailScanner-Information: Please contact the ISP for more information X-shopzeus-MailScanner-ID: 361428895C53.AA487 X-shopzeus-MailScanner: Found to be clean X-shopzeus-MailScanner-From: gandalf@shopzeus.com X-Spam-Status: No X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389604172 news.xs4all.nl 2831 [2001:888:2000:d::a6]:40511 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63818 > Unless L is aliased, this is silly code. There is another use case. If you intend to modify a list within a for loop that goes over the same list, then you need to iterate over a copy. And this cannot be called an "alias" because it has no name: for idx,item in enumerate(L[:]): # do something with L here, including modification -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.