Why does trying to print directly to a file instead of sys.stdout produce the following syntax error:
sys.stdout
Python 2.7.2+ (default, Oct 4 2011, 20:06
This will redirect your 'print' output to a file:
import sys sys.stdout = open("file.txt", "w+") print "this line will redirect to file.txt"