[C++-sig] Overriding c++ abstract class in python

Stefan Seefeld seefeld at sympatico.ca
Mon Aug 18 22:17:33 CEST 2008


William Ladwig wrote:
> python code:
>
> import _core
> class TestInput(_core.GenericInput):
>         def __init__(self):
>                 print("init called")
>   

Make sure to call the base class' __init__ method explicitely. Python, 
unlike C++, won't do that for you automatically:

class TestInput(_core.GenericInput):
    def __init__(self):
        super(TestInput, self).__init__()
        ...

HTH,
       Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...




More information about the Cplusplus-sig mailing list