[C++-sig] Calling a Python function with parameters
Simon Pickles
sipickles at hotmail.com
Fri Jun 8 20:59:26 CEST 2007
Hello,
I've now managed to load a python module using boost::python::exec_file()
I can extract variables and run functions from C++ too.
But I am stumped on how to pass parameters from C++ to a python function.
Not much use without that!
I'm using boost::python::extract<std::string>(global["pyFunc"]) to run the
function, where the python module may be:
##------------------------
def func1():
return "hello from python"
pyFunc = func1()
##-----------------------------------
The docs don't seem to elaborate on how to add parameters. There is plenty
on calling C++ functions from python......
What I want to do is something like this:
// C++
answer = extract<std::string>(global["pyFunc(""hi"", ""there"" )"]
## python
def pyFunc( str1, str2 ):
return str1+str2
Thanks for putting up with a newbie!
Simon
http://www.simonpickles.com --- http://www.squirtualreality.com
_________________________________________________________________
Get a preview of Live Earth, the hottest event this summer - only on MSN
http://liveearth.msn.com?source=msntaglineliveearthhm
More information about the Cplusplus-sig
mailing list