[Tutor] custom container subclassing list-- slices are lists!?

Marcus Goldfish magoldfish at gmail.com
Mon Aug 21 22:50:37 CEST 2006


Hi,

I'd like to sublcass the built-in list type to create my own container.  How
can I make slices of the list be of type myclass-- currently they are
lists.  Example:

>>> class MyFoo(list):
           def __init__(self, inlist):
                  self = inlist[:]
>>> me = MyFoo(range(10))
>>> type(me)
<class '__main__.MyFoo'>

>>> type(me[0:3])
<type 'list'>


All help appreciated!

Thanks,
Marcus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060821/133696df/attachment.html 


More information about the Tutor mailing list