embedded Python sample

Syver Enstad syver-en+usenet at online.no
Tue Sep 10 13:05:18 EDT 2002

monnetb at yahoo.com (bruno Monnet) writes:

> Hi,
> I'm trying to call a python script from my c++ code. All I need is to
> invoke the script and check the return status.
> does anyone has a simple example ? All I found until now is very
> complex and ugly code :-((

I think something like this will do (untested)

void runPythonFile(char* myfile)
FILE* fileptr = fopen(myfile, 'r'); 
int result = PyRun_SimpleFile(fileptr, myfile);
return result;

You should get some ideas by reading the Extending/Embedding section
in the python manual, and then read the relevant sections the Python/C api.


Vennlig hilsen 

Syver Enstad

More information about the Python-list mailing list