Embedding problem
Jp Calderone
exarkun at mudprovider.com
Mon Nov 13 21:18:59 EST 2000
Ok, I'm trying to embed python scripts in a project I'm working on,
so I wrote this little program to try to get the hang of things...
#include "Python.h"
char* code =
"import time\n"
"time.sleep(1.0)\n"
"print \"Hello, World!\"\n";
int main() {
Py_Initialize();
PyObject* globals = PyDict_New();
PyObject* locals = PyDict_New();
if (!globals || !locals)
printf("DOH!\n");
PyObject* result = PyRun_String(code, 0, globals, locals);
Py_Finalize();
return 0;
}
which gives this output...
Adding parser accelerators ...
Done.
Assertion failed
Aborted
I'm guessing I need to do something to put something
useful in locals, at the very least, but I can't seem
to figure out what, or how. I'm also not quite clear
on the second arg. to PyRun_String.. What's "start"?
All help greatly appreciated,
Jp Calderone
More information about the Python-list
mailing list