A question on embedding python and redirecting stderr and stdout

Donn Cave donn at u.washington.edu
Mon Aug 26 12:03:10 EDT 2002


Quoth Jesse Marlin <jesse.marlin at intec-telecom-systems.com>:
| I am embedding python in an application and would like to know
| if it is possible to redirect where python sends its output.
| I have noticed the following functions PySys_WriteStdout and
| PySys_WriteStderr, which write to stdout and stderr.  I do
| not think what I want to do is possible except to change the code
| or forking python stuff.  The reason for wanting this is so I can have
| feedback from executed scripts which is not munged in with all
| other writes to stderr or stdout.  Thanks for any help.

Sure, I bet it's possible.  Depending on your platform, what you
mean by "python sends its output", etc.  In the UNIX world, for
example, you might look at man 2 dup2, which is available in the
posix module.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list