Basic Inheritance Question

Matthew Bell usenet at spling.plus.com
Fri Mar 19 10:17:26 EST 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.

<...deletia...>

> 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]
>  >>>

Ruud,

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,
  Matthew.





More information about the Python-list mailing list