[C++-sig] Inheritance and __init__

Hans Meine hans_meine at gmx.net
Tue Oct 30 11:37:32 CET 2007

On Montag 29 Oktober 2007, Bue Vedel-Larsen wrote:
> I'm having a strange problem with Boost::Python. Consider the following
> Python code:
> class Base:
> 	def foo(self, str):
> 		print str
> class Derived(Base):
> 	def __init__(self):
You must call Base.__init__ here to initialize the base class.
> 		self.foo('__init__')
> d = Derived()
> This works as expected: When run, "__init__" is printed. My problem is
> that if Base is in a C++ module the same code fails with an
> Boost.Python.ArgumentError. See end of post for example code that
> exhibit the error.
the BPL object is not initialized.

Ciao, /  /                                                    .o.
     /--/                                                     ..o
    /  / ANS                                                  ooo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20071030/90bac390/attachment.pgp>

More information about the Cplusplus-sig mailing list