[C++-sig] Executing python code from C++

Murray Cumming murrayc at murrayc.com
Sun Feb 7 11:22:12 CET 2010


In Glom, to execute arbitrary Python code, I use PyRun_String() to parse
the Python code, PyDict_GetItemString() and PyObject_Call() to get a
callable object for that code, and then PyObject_CallObject() to
actually execute the code and get a return value. This was the result of
experimentation and code archeology:
http://git.gnome.org/browse/glom/tree/glom/python_embed/glom_python.cc?h=glom-1-12#n269

Is there anything in boost::python that wraps this, so I can make the
code nicer?

-- 
murrayc at murrayc.com
www.murrayc.com
www.openismus.com



More information about the Cplusplus-sig mailing list