John Dean wrote:
> Hi Duncan
>
> Your version of the app works apart from this part
>
>
>
>
> else {
> PyObject *rString = PyObject_Str(result);
> if (rString==NULL) {
> Py_DECREF(result);
> PyErr_Print();
> return;
> }
John Dean wrote:
> Duncan's example worked to a point. The line PyRun_String( "print x",
> Py_file_input, dict, dict); print out the contents of x, but I don't want to
> print x out. I want to be able to grab whateven the variable x contains so
> that I can pass it on for further processing by the
Hi
Duncan's example worked to a point. The line PyRun_String( "print x",
Py_file_input, dict, dict); print out the contents of x, but I don't want to
print x out. I want to be able to grab whateven the variable x contains so
that I can pass it on for further processing by the C++ application.
BTW
Hi Duncan
Your version of the app works apart from this part
else {
PyObject *rString = PyObject_Str(result);
if (rString==NULL) {
Py_DECREF(result);
PyErr_Print();
return;
}
printf( "The result is %s\n", PyStr
John Dean wrote:
> PyRun_String("def title();", Py_file_input, dict, dict);
> PyRun_String("\treturn 'Foo Bar'", Py_file_input, dict, dict);
> PyRun_String("x = title()", Py_file_input, dict, dict);
> PyObject * result = PyRun_String("print x", Py_file_input, dict, dict);
> printf( "The result is
John Dean wrote:
> Hi
>
> I spent the whole of yesterday trying the get the following C code to
> execute
>
> PyRun_String("def title();", Py_file_input, dict, dict);
^^^
Try using a colon here
> PyRun_String("\treturn 'Foo Bar'", Py_file_input, dict, dict);
> P