[C++-sig] embedded Python: Access an object defined previously in C++

Markus Heller markus at relix.de
Wed Dec 28 09:28:49 CET 2005

Hi Stefan,

> well, I experimented a little with the boost libs, but I see that you can
> only expose entire classes with the class_ method. What I want, though, is
> just to expose a data object to the python program I would like to call
> through the Py/C-API.

I experimented a little with def and with the BOOST_PYTHON_MODULE macro. 
Then I created a little function which just returns "hahaha". I'm glad to say 
that it compiles well. But my question now is the following:

Is it sufficient that the BOOST_PYTHON_MODULE block stands just below all the 
other functions in the according cpp file? 

I want to call a Python script from within one of the functions of this class. 
This Python script will need to import the pipeline module. What are the 
necessare preconditions to allow the script to load my exported function?

Do I need to reset the PYTHONPATH variable? Does this variable need to point 
to where the binary is? Notabene, it is not a shared object...

Thanks ahead for your answers!


More information about the Cplusplus-sig mailing list