I have an application with Python embedded that contains a sip generated module that allows us to script various parts of the application.
It would be extremely helpful if we were able to restart the interpreter
without restarting the application. I've called Py_Finalize() and then
Py_Initialize again, which works fine. The trouble lies with the initialization
of the sip generated module, in this case a function called initqti. After
calling this after a restart all I see is an empty module, i.e. help(qti) gives
no definitions at all.
I have tested this with a small standalone piece of code
#include <Python.h>
extern "C"
{
void initword();
}
int main()
{
PyImport_AppendInittab((char*)"word",initword);
Py_Initialize();
PyRun_SimpleString("print 'Initialized python'");
PyRun_SimpleString("import sys; sys.path.insert(0, '.')");
PyRun_SimpleString("import word; w = word.Word('abc'); print w.reverse()");
PyRun_SimpleString("help(word)");
Py_Finalize();
Py_Initialize();
PyRun_SimpleString("print 'Initialized python again!'");
PyRun_SimpleString("import sys; sys.path.insert(0, '.')");
PyRun_SimpleString("import word; w = word.Word('abc'); print w.reverse()");
PyRun_SimpleString("help(word)");
Py_Finalize();
}
where "word" is the same as the example module given in the sip reference
documentation. I have also attached the complete example.
Is there something fundamentally incorrect about trying this or something that
I don't understand about the workings of sip/python.
Many thanks,
Martyn
--
Scanned by iCritical.
simple_restart.tgz
Description: simple_restart.tgz
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
