PyRun_String with Py_single_input to stdout?

stuart.tett at stuart.tett at
Mon Jun 18 06:45:38 CEST 2007

I'm using PyRun_String with Py_single_input for a python interpreter
embedded in my application. I'm using Py_single_input. Py_single input
is what I want, but it seems to output to stdout. Before when I was
using Py_eval_input I was able to grab the result so I could print it
in a text box:

	  PyObject *resultObject = PyObject_Str( rstring );
	  if( resultObject != NULL ) {
	    char *string = PyString_AsString( resultObject );

But Py_eval_input is only for isolated evaluation, not what I want.
Py_single_input gives "None" for the string.

I wrote a class that redirects std::cout, but this doesn't work for
this, I'm guessing because it uses printf to stdout, not cout.

Anyone know how I can get the string so I can print it in a text box.

More information about the Python-list mailing list