answered Jul 8 '14
Maybe you are looking for this solution:
import sys sys.stdout = open('output.txt','w') print('Hello!')
This way, you only have to use print to write to the file.
print