T
Torsten Bronger
Hallöchen!
I'd like to script C++ funtions by an embedded Python interpreter.
So far, my C++ main() function contains:
Py_Initialize();
Py_InitModule("pp3", PythonMethods);
PyRun_SimpleString("from pp3 import *");
PyRun_AnyFile(stdin, NULL);
Py_Finalize();
"PythonMethods" is the vector of type PyMethodDef that contains the
function descriptors:
static PyMethodDef PythonMethods[] = {
{"toll", py_toll, METH_VARARGS, ""},
{NULL, NULL, 0, NULL}
};
Then I say "toll()" in the input script which calls py_toll() in the
C++ source.
It works. However, is there a way to avoid this dummy "pp3" module
and add the C++ functions directy to the main namespace in the
Python script?
Tschö,
Torsten.
I'd like to script C++ funtions by an embedded Python interpreter.
So far, my C++ main() function contains:
Py_Initialize();
Py_InitModule("pp3", PythonMethods);
PyRun_SimpleString("from pp3 import *");
PyRun_AnyFile(stdin, NULL);
Py_Finalize();
"PythonMethods" is the vector of type PyMethodDef that contains the
function descriptors:
static PyMethodDef PythonMethods[] = {
{"toll", py_toll, METH_VARARGS, ""},
{NULL, NULL, 0, NULL}
};
Then I say "toll()" in the input script which calls py_toll() in the
C++ source.
It works. However, is there a way to avoid this dummy "pp3" module
and add the C++ functions directy to the main namespace in the
Python script?
Tschö,
Torsten.