Capturing PyRun_String stdout

I expect this has been asked before, but I can't find out much about it... I'm trying to embed Python as a scripting language and I need to capture the output of PyRun_String(), PyEval_EvalCode(), or whatever as a char * (or wchar_t * or whatever) rather than have it go to stdout. Python 3.3.2 under plain C, not C++ And, while I'm interrupting everyone's afternoon, another question: if I pass Py_single_input to PyRun_String() or Py_CompileString()/PyEval_EvalCode(), it accepts statements like "a=10" and can then properly do stuff like "print(a)". If I use Py_eval_input instead, I get error messages. In both cases, I'm using the same global_dict and local_dict, if that makes any difference. What am I doing wrong? Thanks, Chris Moller

Hi, 2015-06-30 21:40 GMT+02:00 Chris Moller <moller@mollerware.com>:
I expect this has been asked before, but I can't find out much about it...
Please ask this kind of questions on the python-users mailing list <https://www.python.org/community/lists/> (or comp.lang.python). There you will find helpful people who will tell you how to modify sys.stdout, and the differences between exec() and eval(). Best of luck using Python!
-- Amaury Forgeot d'Arc

Hi, 2015-06-30 21:40 GMT+02:00 Chris Moller <moller@mollerware.com>:
I expect this has been asked before, but I can't find out much about it...
Please ask this kind of questions on the python-users mailing list <https://www.python.org/community/lists/> (or comp.lang.python). There you will find helpful people who will tell you how to modify sys.stdout, and the differences between exec() and eval(). Best of luck using Python!
-- Amaury Forgeot d'Arc
participants (2)
-
Amaury Forgeot d'Arc
-
Chris Moller