int main () { Py_Initialize(); object main_module = import("__main__"); object main_namespace = main_module.attr("__dict__");
try { object result = exec ("import sys\n" "sys.path.append('./')\n" "import test_embed\n" "test_embed.five_square()\n", main_namespace); int five_squared = extract<int> (result); std::cout << five_squared << '\n'; } catch (error_already_set const&) { PyErr_Print(); } } test_embed.py: -------------------- def five_square (): return 5 ** 2 I get: ./test_embed TypeError: No registered converter was able to produce a C++ rvalue of type int from this Python object of type NoneType Why did exec return None? I expected it to return the result of "test_embed.five_squared()", which is the int 25. What is the meaning of the return of exec_file? A python module can't return a result. _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig