Loading modules from files through C++
Stefan Behnel
stefan_ml at behnel.de
Wed May 21 02:33:53 EDT 2014
Roland Plüss, 20.05.2014 19:17:
> PyObject * const loadedModule = Py_InitModule3( fullname, NULL, "Loaded
> module" );
> PyObject * const moduleDict = PyModule_GetDict( loadedModule ); //
> borrowed reference
> PyDict_SetItemString( moduleDict, "__builtins__", PyEval_GetBuiltins() );
> PyRun_StringFlags( fileContent, Py_file_input, moduleDict, moduleDict,
> NULL );
>
> Hopefully this works also in Py3 should I switch some time later. But I
> guess it should seeing how simple the import now became.
The general principle should still work, just the module creation has changed.
Stefan
More information about the Python-list
mailing list