On 9/3/2009 10:10 AM Kreso said...
I am subclassing list class and it basically works, but I don't
understand why after splicing these mylist objects I don't get
returned mylist objects. What I get are list objects:
<snip>
I would prefer that resulting object m belonged to myclist class.
How to obtain such behaviour? Must I somehow implement __getslice__
method myself?


Yep -- something like:

class mylist(list):
    def __init__(self,val=None):
        if val is None:
            list.__init__(self)
        else:
            list.__init__(self,val)
    def __getslice__(self,slstart,slend,slstep=None):
        return mylist(self[slstart:slend:slstep])


Emile


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

Reply via email to