20 inline boost::python::scope
scope(
const std::string & submodule_name)
22 namespace bp = boost::python;
24 bp::scope current_scope;
25 std::string current_scope_name(bp::extract<const char*>(current_scope.attr(
"__name__")));
26 std::string complete_submodule_name = current_scope_name +
"." + submodule_name;
28 bp::object submodule(bp::borrowed(PyImport_AddModule(complete_submodule_name.c_str())));
29 current_scope.attr(submodule_name.c_str()) = submodule;