[C++-sig] Embedding: Creating a Python object with BPL

Jan Heiser jan.heiser at raubtierbaendiger.de
Mon Jun 27 11:15:32 CEST 2005


Hi,

I need to create a Python object (that is completely defined in a python
module) from C++. I can import the module, find the class object and (in
other routines) can access the data and methods of objects. I can even use
the class object to check the validity of objects (using
PyObject_IsInstance). However, I did not find a way to create a new object
based on this class object.

Is there a way with BPL to call the class' constructor somehow? Failing
that, how can one do that using the Python C-API? I can only find
constructors for basic types in there.

There is Py_ObjectNew() but that does take a PyTypeObject* which I don't
have (can I get it from the class object?). Furthermore, I don't see a way
to specify constructor arguments in the call.

Jan.
-- 
<jan.heiser at raubtierbaendiger.de>




More information about the Cplusplus-sig mailing list