N
nik
hi,
my C++ app has embedded the interpreter and calls a python script
everytime it creates a certain data structure. This allows the user to
put the structure into a database or files or whatever. For example;
// Py_Initialize(); has been called earlier
m_module = PyImport_AddModule("myModule");
// for example, this string is my data structure
PyObject* theMessage = PyString_FromString("data");
PyModule_AddObject(my_module, "Message", theMessage);
fp =fopen("theScript.py", "r");
PyRun_SimpleFile(fp, "theScript.py");
// Py_Finalize(); will be called when the C++ app exits
I've just realised that calling the script repeatedly might not be the
best thing, especially if the users script has a lot of initialisation
to do, or needs to store variables in between calls to the script.
How could I solve this? Can the user run a python program alongside my
C++ app, and the app call a method on the users program? I.e. can the
script I call be part of a global process in some way? Or, are there
other ways to go about this?
nik
my C++ app has embedded the interpreter and calls a python script
everytime it creates a certain data structure. This allows the user to
put the structure into a database or files or whatever. For example;
// Py_Initialize(); has been called earlier
m_module = PyImport_AddModule("myModule");
// for example, this string is my data structure
PyObject* theMessage = PyString_FromString("data");
PyModule_AddObject(my_module, "Message", theMessage);
fp =fopen("theScript.py", "r");
PyRun_SimpleFile(fp, "theScript.py");
// Py_Finalize(); will be called when the C++ app exits
I've just realised that calling the script repeatedly might not be the
best thing, especially if the users script has a lot of initialisation
to do, or needs to store variables in between calls to the script.
How could I solve this? Can the user run a python program alongside my
C++ app, and the app call a method on the users program? I.e. can the
script I call be part of a global process in some way? Or, are there
other ways to go about this?
nik