It sounds like you want to use print >> If you have an open object with a "write" property, you can do print >> thefile, mystring and Python will simply redirect the output to "thefile" instead of sys.stdout.