Redirect question

Chris Liechti cliechti at gmx.net
Sun Nov 17 10:39:33 EST 2002


k.weinert at gmx.net (Karsten Weinert) wrote in 
news:fa576652.0211170745.2328fe56 at posting.google.com:
> I have a question about redirecting. Here is a small program I found
> on the web which I slightly modified; but now it does not run:
> 
> import win32ui, sys
> 
> class Redirect:
>   def __init__(self):
>     self.s=""
>   def write(self, s):
>     self.s+=s
>   def flush(self):
>     win32ui.MessageBox(s)

that cannot work.

   def flush(self):
     win32ui.MessageBox(self.s)
    	self.s = ""

has better chances

> sys.stdout = sys.stderr = Redirect()
> 
> print 'Hidey Ho'
> sys.stdout.flush()

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list