Movatterモバイル変換
[0]ホーム
Problem restarting the interpreter (bug?)
Aaron Drewripper 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 modulespam, everything works fine but if I use this code then the function doesn'tget 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 problemsimporting 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 thepython doc's and code as best I can but can't seem to figure out why this ishappening.Regards,Aaron
More information about the Python-listmailing list
[8]ページ先頭