On 6/8/07, Simon Pickles <sipickles hotmail.com> wrote:
> 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["pyFun
c"]) 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(""h
i"", ""there"" )"]
>
> ## python
> def pyFunc( str1, str2 ):
> return str1+str2
>
> Thanks for putting up with a newbie!
I guess this is what your are looking for:
http://
boost.org/libs/python/doc/v2/call.html
--
Roman Yakovenko
C++ Python language binding
http://www.language-
binding.net/
_______________________________________________
C++-sig mailing list
C++-sig python.org
http:
//mail.python.org/mailman/listinfo/c++-sig
|