Basic Inheritance Question

Matthew Bell usenet at
Fri Mar 19 16:17:26 CET 2004

Ruud de Jong wrote:

> Matthew Bell schreef:

> > I've got a conceptual problem to do with inheritance.  
> > I'd be grateful if someone could help to clear up my 
> > confusion.


> You were nearly there. You don't need a <magictoken>;
> __init__ does not return anything.
> Just initialize the baseclass with the things you want:

>  >>> class myList(list):
> 	def __init__(self):
> 		list.__init__(self, [1,2,3])

>  >>> m = myList()
>  >>> m
> [1, 2, 3]
>  >>>


The light has come on!  Thanks very, very much for the 
pointer.  Given Python's general elegance I knew there 
must be an obvious way of doing this but I just couldn't
see it.  I do now.

Thanks again,

More information about the Python-list mailing list