On Thursday, February 13, 2003 2:51:02 PM UTC+2, Mike Müller wrote: > "Mark McEahern" <markli...@mceahern.com> wrote in message > news:<mailman.1045085143.24238.python-l...@python.org>... > > Same basic idea: > > > > #!/usr/bin/env python > > > > import sys > > > > class MyWriter: > > > > def __init__(self, stdout, filename): > > self.stdout = stdout > > self.logfile = file(filename, 'a') > > > > def write(self, text): > > self.stdout.write(text) > > self.logfile.write(text) > > > > def close(self): > > self.stdout.close() > > self.logfile.close() > > > > writer = MyWriter(sys.stdout, 'log.txt') > > sys.stdout = writer > > > > print 'test' > > > > Hi Mark, > > works perfect. Just had to change ´file´ to ´open´ for my Python 2.1. > Adding the method ´flush(self)´ to Writer helped to get my > ´sys.stdout.flush()´ to work. > > Thanks also to two inches (previous post). > > > Mike
Hay Mike, Can you tell me how & where you added the 'flush(self)' & 'sys.stdout.flush()'? Thanks! Ami -- http://mail.python.org/mailman/listinfo/python-list