It wouldn't be too difficult to write a file object wrapper that emulates tee, for instance (untested):
class tee(object): def __init__(self, file_objs, autoflush=True): self._files = file_objs self._autoflush = autoflush def write(self, buf): for f in self._files: f.write(buf) if self._autoflush: self.flush() def flush(self): for f in self._files: f.flush() use like so: sys.stdout = tee([sys.stdout, open("myfile.txt", "a")]) Another approach is by bsandrow (https://github.com/bsandrow/pytee), which uses fork and os.pipe(), this more closely resembles what the actual tee command are actually doing. -- https://mail.python.org/mailman/listinfo/python-list