Suggestion: PEP for popping slices from lists

Neatu Ovidiu neatuovi at gmail.com
Thu Aug 8 07:40:19 EDT 2013


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... at 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 you seem to want is to create lists based on other lists) - but maybe I'm missing something.  Could we have one example?
> 
> 
> 
> N.

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', 'job7', 'job8', 'job9', 'job10']
while jobs:
    print jobs.pop_slice(0,4)



More information about the Python-list mailing list