For reference to posterity, this is how I got it to work in the end:
PyObject* module = PyImport_ImportModule("__builtin__");
PyObject* obj = PyRun_String("1", Py_eval_input,
PyModule_GetDict(module), NULL);
Py_DECREF(module);
long d = PyLong_AsLong(obj);
printf("long:%ld\n", d);
Py_DE
Here is what I tried, but it prints out '-1':
PyObject* obj = PyRun_String("1", Py_single_input,
PyEval_GetGlobals(), PyEval_GetLocals());
long d = PyLong_AsLong(obj);
printf("long:%ld\n", d);
Py_DECREF(obj);
Peter
On Sep 30, 9:24 pm, Thomas Jollans wrote:
> On Thursday 30 September 2010, it oc
On Thursday 30 September 2010, it occurred to pbienst to exclaim:
> Hi,
>
> I'm embedding Python in a C app.
>
> Say I do the following:
>
> PyRun_SimpleString("a = 1")
>
> Is there then a way to get access to the PyObject corresponding to a,
> only making use in C of the fact that it's calle
Hi,
I'm embedding Python in a C app.
Say I do the following:
PyRun_SimpleString("a = 1")
Is there then a way to get access to the PyObject corresponding to a,
only making use in C of the fact that it's called "a"?
I've searched through the API docs, but I couldn't really find what I
was look