[C++-sig] Embedding: Creating a Python object with BPL
Stefan Seefeld
seefeld at sympatico.ca
Mon Jun 27 11:46:11 CEST 2005
Jan Heiser wrote:
> 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
Just call it !
boost::python::object cls = ...
boost::python::object instance = cls();
> that, how can one do that using the Python C-API? I can only find
> constructors for basic types in there.
Regards,
Stefan
More information about the Cplusplus-sig
mailing list