Philippe C. Martin wrote:
> I guess my slicing was wrong, l[-1] worked

Note that that's _not_ a slice, however, but a reference to the last 
element in the list.

You'd have to subclass list to be able to do something with 
"reference-slices".  Probably returning a special object from 
__getslice__ which itself has references back to the original list and 
implements any changes back in the original instead of in itself.  I 
haven't tried to imagine if this is even feasible.

Anything "indexing" with : in it is a slice, so a copy, while anything 
with only a single index as you have in l[-1] is just a reference to one 
element in the list.

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to