[C++-sig] redirect to file

Nicodemus nicodemus at esss.com.br
Fri Nov 7 15:30:36 CET 2003


F.G.Testa wrote:

>Hi all!
>I'm new to python and I'm embedding into a Win32 service application.
>So far I couldn't redirect the output from Python's 'print' command to a
>file. The CRT freopen seems not work. Also, when I call PyErr_Print() has
>the same
>behavior.
>

Try executing this code in Python:

import sys
sys.stdout = open('myfile', 'w')

You can use PyRun_String() for that.

HTH,
Nicodemus.





More information about the Cplusplus-sig mailing list