Altering 'print'/mod_python

Remco Gerlich scarblac at pino.selwerd.nl
Tue May 15 02:59:57 EDT 2001


Jeff Davis <jdavis at empires.org> wrote in comp.lang.python:
> Thanks for the help. I found out that sys.__stdout__ holds the original 
> stdout, so I can use that rather than a temp variable:

Unless some other part of the program has already redirected it :)

> import sys
> sys.stdout = foo
> ...
> sys.stdout = sys.__stdout__

And don't forget the try: finally:.

-- 
Remco Gerlich



More information about the Python-list mailing list