[C++-sig] Redirecting stdout/stderr
koestler
koestler at ee.uwa.edu.au
Mon Apr 19 06:12:08 CEST 2004
Hi,
I am using Python as an embedded scripting language within a wxWindows application. To redirect the stdout/stderr I'm using the following module:
import sys
class StdoutCatcher:
def __init__(self):
self.data = ''
def write (self,stuff):
self.data = self.data + stuff
def redirectStdout():
sys.stdout = StdoutCatcher ( )
def redirectStderr():
sys.stderr = StdoutCatcher ( )
def getStdout():
return sys.stdout.data
def getStderr():
return sys.stderr.data
This gives me access to the interpreter's I/O if the I/O has happened within the module. Now I want the user to be able to interactively type in Python commands using PyRun_SimpleString.
Is there a way to access the stdout/stderr that way? Thanks for your help.
Ca folks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040419/42d2d224/attachment.htm>
More information about the Cplusplus-sig
mailing list