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


Groups > comp.lang.python > #52231

Re: Suggestion: PEP for popping slices from lists

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Suggestion: PEP for popping slices from lists
Date 2013-08-08 18:10 -0400
References (2 earlier) <531d89a8-61e1-4117-b4cc-f02b3be30bb9@googlegroups.com> <mailman.347.1375960376.1251.python-list@python.org> <9bd6192b-2c71-4662-808a-fd7e74dedeb8@googlegroups.com> <ku0tia$nkk$1@ger.gmane.org> <CAN1F8qX4iMG_pE_0B4ukc2k8HtHVUni5dLtsv=QAP5iMO+9O_Q@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.376.1375999869.1251.python-list@python.org> (permalink)

Show all headers | View raw


On 8/8/2013 5:32 PM, Joshua Landau wrote:
> On 8 August 2013 21:03, Terry Reedy <tjreedy@udel.edu> 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

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


Thread

Suggestion: PEP for popping slices from lists Neatu Ovidiu Gabriel <neatuovi@gmail.com> - 2013-08-08 02:45 -0700
  Re: Suggestion: PEP for popping slices from lists Peter Otten <__peter__@web.de> - 2013-08-08 12:07 +0200
    Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 03:38 -0700
      Re: Suggestion: PEP for popping slices from lists Nicholas Cole <nicholas.cole@gmail.com> - 2013-08-08 12:12 +0100
        Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 04:40 -0700
          Re: Suggestion: PEP for popping slices from lists Skip Montanaro <skip@pobox.com> - 2013-08-08 09:20 -0500
        Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 04:44 -0700
          Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 04:50 -0700
            Re: Suggestion: PEP for popping slices from lists Nicholas Cole <nicholas.cole@gmail.com> - 2013-08-08 14:08 +0100
              Re: Suggestion: PEP for popping slices from lists Neatu Ovidiu <neatuovi@gmail.com> - 2013-08-08 06:32 -0700
                Re: Suggestion: PEP for popping slices from lists Nicholas Cole <nicholas.cole@gmail.com> - 2013-08-08 15:03 +0100
          Re: Suggestion: PEP for popping slices from lists Terry Reedy <tjreedy@udel.edu> - 2013-08-08 16:03 -0400
          Re: Suggestion: PEP for popping slices from lists Joshua Landau <joshua@landau.ws> - 2013-08-08 22:32 +0100
          Re: Suggestion: PEP for popping slices from lists Tim Chase <python.list@tim.thechases.com> - 2013-08-08 16:50 -0500
          Re: Suggestion: PEP for popping slices from lists Terry Reedy <tjreedy@udel.edu> - 2013-08-08 18:10 -0400

csiph-web