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
You can export print statement to file without changing any code. Simply open a terminal windows and run your code in this way:
python yourcode.py >> log.txt