On 22/08/06, Marcus Goldfish <[EMAIL PROTECTED]> wrote: > >>> class MyFoo(list): > def __init__(self, inlist): > self = inlist[:]
Um, I'm fairly sure this line is not doing what you think it is doing! self is just a local variable. When __init__ is called, self is bound to the MyFoo instance. But when you do 'self = inlist[:]', you just rebind it to a copy of inlist. You aren't changing self.. > >>> me = MyFoo(range(10)) > >>> type(me) > <class '__main__.MyFoo'> > > >>> type(me[0:3]) > <type 'list'> Have you tried implementing __getitem__ and __setitem__ for slice objects? (see http://docs.python.org/ref/sequence-methods.html and http://docs.python.org/ref/sequence-types.html#l2h-231) -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor