[C++-sig] instantiating python objects within C++

Adam Hupp hupp at cs.wisc.edu
Fri May 23 21:01:27 CEST 2003


On Fri, May 23, 2003 at 02:34:05PM -0400, Stefan Seefeld wrote:
> 
> ...how can I instantiate a python object in C++ ?
> 
> I'v defined a C++ class, wrapped it into a python
> class, and now want to call a python function
> using an object of that type. Read: I want to
> provide python 'callbacks' that let people interact
> with my C++ application, but in python.
> 
> I'v set up the python interpreter and can run it
> successfully. All I'm missing is a way to instantiate
> objects of said type and inject them into the namespace
> that is passed to the PyRun_File call...

Try looking at libs/python/test/embedding.cpp.  It has a nice example
of this usage.  

-Adam




More information about the Cplusplus-sig mailing list