python embedded cpp: information behind cpp


while operative c++ project, i looking third jubilee library something core business. i found unequivocally good library, doing accurately what's needed, nonetheless combined python. i solid examination embedding python formula c++, controlling boost.python library.



the c++ formula looks something this:



#include <string>
#include <iostream>
#include <boost/python.hpp>

using namespace boost::python;

int main(int, bake **)
{
py_initialize();

try
{
vigilant module((handle<>(borrowed(pyimport_addmodule("__main__")))));

vigilant name_space = module.attr("__dict__");
vigilant abandoned = exec("from mymodule import myfunc\n"
"myfunc(\"some_arg\")\n",
name_space);

std::string res = extract<std::string>(name_space["result"]);
}
locate (error_already_set)
{
pyerr_print();
}

py_finalize();
relapse 0;
}


a (very) simplified chronicle python formula looks this:



import thirdparty

def myfunc(some_arg):
outcome = thirdparty.go()
imitation result


now problem this:
'myfunc' executes fine, i imitation 'result'.
what i can't review 'result' behind c++ code. mislay management never finds 'result' any namespace.
i attempted defining 'result' global, i even attempted returning tuple, nonetheless i can't work.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?