error when importing
Arno Baan
a.baan at fokkerspace.nl
Wed Jan 23 07:40:42 EST 2002
Hi I have the following code:
static PyMethodDef EmbMethods[] = {
{"getSchedParamValue", emb_getSchedParamValue, METH_VARARGS, "Get
parameter value."},
{NULL, NULL, 0, NULL}
};
void main(){
PyObject * pdict, * pmod;
Py_Initialize();
Py_InitModule("emb", EmbMethods);
pdict = PyDict_New();
PyDict_SetItemString(pdict,"_builtins_", PyEval_GetBuiltins());
PyRun_SimpleString("import emb\nprint emb.getSchedParamValue(10, 'freq',
'string')\nprint 'SimpleString'");
PyRun_String("import emb\nprint emb.getSchedParamValue(10, 'freq',
'string')\nprint 'SimpleString'", Py_file_input, pdict, pdict);
Py_Finalize();
}
wich according to me should import a function I've written in C++ and call
on it through the python interpreter.
The problem is, this works with the PyRun_SimpleString function, but not
with the PyRun_String function.
I need the python interpreter to be able to return a value after doing some
calculations using the C++ function and
i understand that this is not possible using te SimpleString function.
Can someone help me please?
greetz arno
More information about the Python-list
mailing list