You can always implement your own data-structures or simply a function
if you need so. A language consist of building blocks and not buildings.
<br><br><div class="gmail_quote">On Sun, Feb 21, 2010 at 6:36 AM, Jonathan Gardner <span dir="ltr"><<a href="mailto:jgardner@jonathangardner.net">jgardner@jonathangardner.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On Sat, Feb 20, 2010 at 4:55 PM, marwie <<a href="mailto:marwie@gmx.de">marwie@gmx.de</a>> wrote:<br>
> Hello,<br>
><br>
> I recently read about augmented assignments and that (with l1, l2<br>
> being lists)<br>
><br>
> l1.extend(l2)<br>
><br>
> is more efficient than<br>
><br>
> l1 = l1 + l2<br>
><br>
> because unnecessary copy operations can be avoided. Now my question is<br>
> if there's a similar thing for breaking a list into two parts. Let's<br>
> say I want to remove from l1 everything from and including position 10<br>
> and store it in l2. Then I can write<br>
><br>
> l2 = l1[10:]<br>
> del l1[10:]<br>
><br>
> But since I'm assigning a slice the elements will be copied.<br>
> Basically, I'm looking for something like l1.pop(10,len(l1)) which<br>
> returns and removes a whole chunk of data. Is there such a thing (and<br>
> if not, why not?)<br>
><br>
<br>
</div></div>The idiom is:<br>
<br>
>>> l1, l2 = l1[:10], l1[10:]<br>
<br>
Don't know if it's optimized or not. If it's not, it could probably<br>
be. This is a really common idiom.<br>
<font color="#888888"><br>
--<br>
Jonathan Gardner<br>
<a href="mailto:jgardner@jonathangardner.net">jgardner@jonathangardner.net</a><br>
</font><div><div></div><div class="h5">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>