[C++-sig] Fwd: Passing Python-derived class back into a native C++ class doesn't match the C++ signature
Jim Bosch
talljimbo at gmail.com
Sat Nov 12 20:25:42 CET 2011
On 11/12/2011 02:12 PM, Adam Preble wrote:
> Woooah that looks like it does work, although I had to interpret it like so:
>
> class DerivedTest(BaseTest):
> def __init__(self):
> BaseTest.__init__(self)
>
> def GimmeNumber(self):
> return 100
>
> I don't really consider myself an expert on these things, though I was
> Googling around on the proper way to handle the inheritance construction
> in Python. Is this kind of the normal rigors when subclassing in Python
> normally, or is this something I must particularly pay attention to when
> using Boost?
>
Calling the base class __init__ is less important in pure Python (i.e.
sometimes it's not necessary), but it's still definitely good practice;
it depends on whether the base class __init__ does anything important.
Python does not ever call it automatically, and in Boost.Python it
definitely does something important.
Jim
More information about the Cplusplus-sig
mailing list