redirecting stderr back..

rh0dium steven.klass at gmail.com
Fri Jan 9 18:17:48 EST 2009


On Jan 9, 3:42 pm, Robert Kern <robert.k... at gmail.com> wrote:
> 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

Interesting stuff - but the documentation is a bit lacking - but I
think I can figure it out.




More information about the Python-list mailing list