<div dir="ltr"><div class="gmail_extra">On Thu, Aug 8, 2013 at 12:50 PM, Neatu Ovidiu <span dir="ltr"><<a href="mailto:neatuovi@gmail.com" target="_blank">neatuovi@gmail.com</a>></span> wrote:<br><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thursday, August 8, 2013 2:44:05 PM UTC+3, Neatu Ovidiu wrote:<br>
> On Thursday, August 8, 2013 2:12:53 PM UTC+3, Nicholas wrote:<br>
><br>
> > On Thu, Aug 8, 2013 at 11:38 AM, Neatu Ovidiu <<a href="mailto:neat...@gmail.com">neat...@gmail.com</a>> wrote:<br>
><br>
> ><br>
><br>
> ><br>
><br>
> ><br>
><br>
> ><br>
><br>
> ><br>
><br>
> ><br>
><br>
> ><br>
><br>
> > > But what's your use case?<br>
><br>
> ><br>
><br>
> > ><br>
><br>
> ><br>
><br>
> > > Does it occur often enough that you cannot afford a two-liner like<br>
><br>
> ><br>
><br>
> > I think uses cases are plenty.<br>
><br>
> ><br>
><br>
> ><br>
><br>
> ><br>
><br>
> ><br>
><br>
> > 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?<br>

><br>
> ><br>
><br>
> ><br>
><br>
> ><br>
><br>
> > N.<br>
><br>
><br>
><br>
> 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.<br>
><br>
><br>
><br>
> jobs = ['job1', 'job2', 'job3', 'job4', 'job5', 'job6', 'job7', 'job8', 'job9', 'job10']<br>
><br>
> while jobs:<br>
><br>
>     print(jobs.pop_slice(0,4))<br>
><br>
><br>
><br>
> should output<br>
><br>
><br>
><br>
> 'job1', 'job2', 'job3', 'job4'<br>
><br>
> 'job5', 'job6', 'job7', 'job8'<br>
><br>
> 'job9', 'job10'<br>
<br>
</div></div>The idea "popped" in my mind while thinking about this question.<br>
<a href="http://stackoverflow.com/questions/18121416/right-split-a-string-into-groups-of-3/18122084" target="_blank">http://stackoverflow.com/questions/18121416/right-split-a-string-into-groups-of-3/18122084</a><br>
I founded the list comprehensions solutions kind of cumbersome and thought that there should be a simple way to do this kind of stuff.<br>
<span class="HOEnZb"><font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra" style>Still seems a bit like a solution looking for a problem to me.</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>
Why would you want to take four items at a time for a job from an arbitrary part of a list?  I agree splitting a string into groups of three looks a bit cumbersome in the example you've given, but a generator could be written quite easily, and would almost certainly be quicker than trying to alter the list in place.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>Best wishes,</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>N.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>