Suggestion: PEP for popping slices from lists

2013-08-08 Thread Neatu Ovidiu Gabriel
The list.pop(index) returns the element represented by the index and also reduces the list by removing that element. So it a short one liner for doing both things. But when it comes for popping a slice of the list there is nothing similar for doing in that simple way. If you want to remove a

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Peter Otten
Neatu Ovidiu Gabriel wrote: The list.pop(index) returns the element represented by the index and also reduces the list by removing that element. So it a short one liner for doing both things. But when it comes for popping a slice of the list there is nothing similar for doing in that simple

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Neatu Ovidiu
On Thursday, August 8, 2013 1:07:16 PM UTC+3, Peter Otten wrote: Neatu Ovidiu Gabriel wrote: The list.pop(index) returns the element represented by the index and also reduces the list by removing that element. So it a short one liner for doing both things. But when it comes for

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Nicholas Cole
On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu neatu...@gmail.com wrote: But what's your use case? Does it occur often enough that you cannot afford a two-liner like I think uses cases are plenty. The possible cases I can think of would be better served with list comprehensions (what

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Neatu Ovidiu
On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote: On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu neat...@gmail.com wrote: But what's your use case? Does it occur often enough that you cannot afford a two-liner like I think uses cases are plenty. The

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Neatu Ovidiu
On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote: On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu neat...@gmail.com wrote: But what's your use case? Does it occur often enough that you cannot afford a two-liner like I think uses cases are plenty. The

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Neatu Ovidiu
On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote: On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote: On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu neat...@gmail.com wrote: But what's your use case? Does it

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Nicholas Cole
On Thu, Aug 8, 2013 at 12:50 PM, Neatu Ovidiu neatu...@gmail.com wrote: On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote: On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote: On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu neat...@gmail.com wrote:

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Neatu Ovidiu
On Thursday, August 8, 2013 4:08:13 PM UTC+3, Nicholas wrote: On Thu, Aug 8, 2013 at 12:50 PM, Neatu Ovidiu neat...@gmail.com wrote: On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote: On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote: On Thu, Aug 8,

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Nicholas Cole
On Thu, Aug 8, 2013 at 2:32 PM, Neatu Ovidiu neatu...@gmail.com wrote: On Thursday, August 8, 2013 4:08:13 PM UTC+3, Nicholas wrote: On Thu, Aug 8, 2013 at 12:50 PM, Neatu Ovidiu neat...@gmail.com wrote: On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote: On

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Skip Montanaro
On Thu, Aug 8, 2013 at 6:40 AM, Neatu Ovidiu neatu...@gmail.com wrote: This can be useful for doing all kinds of basic stuff. For example if you wanted to take 4 items of a list at at a time, do something with them and then update the list. jobs = ['job1', 'job2', 'job3', 'job5', 'job6',

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Terry Reedy
On 8/8/2013 7:44 AM, Neatu Ovidiu wrote: Objection 1. People usually want to chunk sequences, not lists specifically. We now try to add new features that work with iterators and iterables generally, not just lists. This can be useful for doing all kinds of basic stuff. For example if you

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Joshua Landau
On 8 August 2013 21:03, Terry Reedy tjre...@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

Re: Suggestion: PEP for popping slices from lists

2013-08-08 Thread Tim Chase
On 2013-08-08 22:32, Joshua Landau wrote: On 8 August 2013 21:03, Terry Reedy tjre...@udel.edu wrote: If .pop were being added today, I would argue against including the index parameter. 3) There's always deque for deques Unless you have pre-2.4 code, in which case I'm glad .pop() was

Re: Suggestion: PEP for popping slices from lists

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