Problem restarting the interpreter (bug?)
Aaron Drew
ripper at hotkey.net.au
Sat Apr 21 06:11:17 EDT 2001
Hi,
I'm running into two problems just after running the following code C code:
void InitPython()
{
// Initialize the Python interpreter. Required.
Py_Initialize();
if(!Py_IsInitialized())
printf("Py_Initialize() failed\n");
// Add internal modules
initspam();
// Import python modules
if(!PyImport_ImportModule("sys"))
printf("import sys failed\n");
if(!PyImport_ImportModule("spam"))
printf("import spam failed\n");
}
My first problem - If I use PyEval_CallObject to call a function in module
spam, everything works fine but if I use this code then the function doesn't
get called:
PyRun_SimpleString("spam.setstring('foo')\n");
My second problem - Restarting the interpreter. If I do:
Py_Finalize();
InitPython(); // (this is the function listed above)
I can no longer import any external modules (.py files). I have no problems
importing sys or spam but anything from the lib or current directories fail.
Any help what-so-ever with these would be appreciated. I've gone through the
python doc's and code as best I can but can't seem to figure out why this is
happening.
Regards,
Aaron
More information about the Python-list
mailing list