Re: Problem with C-API

2006-03-18 Thread Duncan Booth
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; > }

Re: Problem with C-API

2006-03-18 Thread Fredrik Lundh
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

Re: Problem with C-API

2006-03-17 Thread John Dean
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

Re: Problem with C-API

2006-03-17 Thread John Dean
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

Re: Problem with C-API

2006-03-17 Thread Duncan Booth
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

Re: Problem with C-API

2006-03-17 Thread Diez B. Roggisch
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