import sys,os class IHOut(file): def __init__(s,fd=sys.stdout.fileno()): s.fd = fd def write(s, str): os.write(fd,str) sys.stdout = IHOut() print "This is a test."