Subclassing list and splicing

Kreso kkOHNOumer at donoevil.com
Thu Sep 3 16:52:25 EDT 2009


Kreso <kkNOWAYumer at donoevil.com> wrote:
[...]
> I would prefer that resulting object m belonged to myclist class.

I forgot to add that mylist instances in my case have some attributes (that's
why I need special container class in the first place) which should be
preserved after splicing.
  In my simple understaning of python it looks to me that list splicing
has to involve copying (i.e. cannot be done only by referencing), and since 
base class 'list' doesn't know anything about mylist attributes, I will certainly 
have to override list's __getslice__ method, right? The only question
is how to re-use as much of the 'lists' methods as possible, so that
at list I don't need to write the code for copying of contained
elements.



More information about the Python-list mailing list