Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.87.MISMATCH!newsfeed.xs4all.nl!newsfeed1.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'pop': 0.05; 'subject:PEP': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.12; '-1):': 0.16; '-1,': 0.16; 'mutability': 0.16; 'parameter.': 0.16; 'popping': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'index': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'somewhere': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'that.': 0.31; 'argue': 0.31; 'index,': 0.31; 'subject:from': 0.34; 'something': 0.35; 'subject:lists': 0.35; 'done': 0.36; 'being': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'middle': 0.60; 'removing': 0.60; 'august': 0.61; 'today,': 0.61; 'received:173': 0.61; "you're": 0.61; 'experience.': 0.67; 'believe': 0.68; 'different.': 0.84; 'received:fios.verizon.net': 0.84; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Suggestion: PEP for popping slices from lists Date: Thu, 08 Aug 2013 18:10:52 -0400 References: <531d89a8-61e1-4117-b4cc-f02b3be30bb9@googlegroups.com> <9bd6192b-2c71-4662-808a-fd7e74dedeb8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375999869 news.xs4all.nl 15882 [2001:888:2000:d::a6]:58692 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52231 On 8/8/2013 5:32 PM, Joshua Landau wrote: > On 8 August 2013 21:03, Terry Reedy wrote: >> If .pop were being added today, I would argue against including the index >> parameter. > > GASP! That's no fair! > > 1) When using pop you normally want to keep the mutability available, > so iter(mylist) is a no-go. > 2) When using the index, it's often somewhere in the middle that > you're popping from I have never done that and I do not believe I have ever seen that. It certainly is extremely rare in my experience. Removing an item *after* looking at it is something different. for i in range(len(mylist), -1, -1): if pred(mylist[i]): del mylist[i] -- Terry Jan Reedy