[C++-sig] Re: The easiest way to evoke a python function from a C++ application...?

David Abrahams dave at boost-consulting.com
Fri Feb 20 23:16:30 CET 2004

Billy Gnosis <sirbender at freenet.de> writes:

> What is the easiest way to evoke a python function from a C++ application ?
> I just want it for testing reasons and perhaps use it as a new way to
> develop software.
> I am new into python, but admire the fast and easy way to write code.
> Actually I planned to set up most of the program in C++ in a more or
> less complete way - this should be quickly possible by using Python
> functions, that are later replaced by C code when the "design" of the
> program is ok.
> So I just want to call e.g. a python function string.split(...) and
> return an array of strings to the C-Program. How is this most easily
> done ? It can be very 'dirty' as it will be replaced later
> anyway. Does somebody has example code?

#include <boost/python/str.hpp>
#include <boost/python/list.hpp>

namespace py = boost::python;

  py::list split_strings = py::str('whatever').split(whatver-else)

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list