redirecting stderr back..
Robert Kern
robert.kern at gmail.com
Fri Jan 9 17:42:46 EST 2009
Christian Heimes wrote:
> rh0dium schrieb:
>> Hi All,
>>
>> Can someone tell me how to redirect stderr back to the console once
>> you've moved it?
>
> sys.stderr = sys.__stderr__
>
> or better:
>
> orig_stderr = sys.stderr
> try:
> sys.stderr = open(...)
> ...
> finally:
> sys.stderr = orig_stderr
He's not reassigning the sys.stderr object; he's fiddling with the underlying
file descriptor.
Steven, look at my code here for a mostly complete solution:
http://www.enthought.com/~rkern/cgi-bin/hgwebdir.cgi/redir/
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list