[Tutor] Inheriting Classes and __init__

Wesley Brooks wesbrooks at gmail.com
Fri Jan 26 15:09:09 CET 2007


Thanks again, that is a great help.

Wesley Brooks

On 26/01/07, Kent Johnson <kent37 at tds.net> wrote:
> Wesley Brooks wrote:
> > Dear Users,
> >
> > I would like a class to inherit the methods from wxVTKRenderWindow,
> > but to add a few lines of code to __init__ . I would prefer not to
> > copy the whole init method from the inherited class into the
> > inheriting class. What is the best approach for this? I guess that if
> > I have an init in the inheriting class it would overide the init in
> > the inherited class?
>
> Yes, your __init__() will override the base class __init__(). To include
> the base class functionality, just call the base class __init__() from
> your __init__(). The syntax for this is a little different from the
> usual method call; in your __init__() include this call:
>    wxVTKRenderWindow.__init__(self, args)
>
> where args is whatever argument list you want to pass to the base class
> __init__().
>
>
>


More information about the Tutor mailing list