[Tutor] Inheriting Classes and __init__

Kent Johnson kent37 at tds.net
Fri Jan 26 15:03:30 CET 2007


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