Embedding Python in C++

Pecks gregphillips13 at hotmail.com
Wed Feb 4 17:34:42 CET 2004


Hi, 

I'm having problems embedding Python in C++. 
(Background - I'm hacking a COTS app 
written in C++, and I'd like to write in some intelligence in
Python)

I understand that I can call a python objects method
using PyImport_ImportModule, PyObject_GetAttrString and
PyObject_CallMethod. 

But this method relies on the object being declared and initialsed
within my Python code. It also depends on hard-coding the name 
of the python object in the C++ code, which is nasty. 

Is there a better way of doing this? 
Is it necessary / a good idea to use Boost or Swig?
I'd rather code it by hand using the Python C API if possible. 

Thanks, 

Greg.



More information about the Python-list mailing list