Why can't I restore my redirected stdout?

Rainer Deyke root at rainerdeyke.com
Thu Jun 8 19:51:15 EDT 2000


<andres at corrada.com> wrote in message
news:20000608150314.A26601 at corrada.com...
> On Fri, Jun 09, 2000 at 01:52:52AM +0800, Raymond Ng Tong Leng wrote:
> > class Quiet:
> >     def write(self, data):
> >         pass
> > >>> sys.stdout = Quiet()
> > >>> print 'hello'
> > >>> sys.stdout = sys.__stdout__
> > >>> print 'hello'

> sys.stdout and sys.__stdout__ point to the same object. Save the default
> sdtout before you redefine it:

If sys.stdout and sys.__stdout__ point to the same object, and you assign
some other object to sys.stdout, it is be possible to restore it by
assigning sys.__stdout__ to sys.stdout.


--
Rainer Deyke (root at rainerdeyke.com)
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list