Newbie: Capture output of compile_dir

Peter Hansen peter at engcorp.com
Tue Jul 16 07:57:45 EDT 2002


"Denis S. Otkidach" wrote:
> 
> Informational messages from compile_dir go to stdout and error
> messages go to stderr.  You should redefine both.
> 
> orig_so = sys.stdout
> orig_se = sys.stderr
> sys.stdout = sys.stderr = captured = StringIO()
> ...

By the way, "sys" has _stdout and _stderr already, which I believe
point to the originals, so I believe you don't need to preserve 
these in your own locals unless you're expecting to have to nest
these sorts of redirections.

-Peter



More information about the Python-list mailing list