Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, os
- class Tee(object):
- def __init__(self, filename):
- self.teeFile = open(filename, "w")
- self.stdout = sys.__stdout__
- sys.__stdout__ = self
- def __del__(self):
- self.restore()
- def restore(self):
- sys.__stdout__ = self.stdout
- self.teeFile.close()
- def write(self, val):
- self.teeFile.write(val)
- self.stdout.write(val)
- self.teeFile.flush()
- tee = Tee("c:/log.txt")
Advertisement
Add Comment
Please, Sign In to add comment