Redirecting Python Output to File
February 13, 2010
I have a script that is written in python, and I have a wrapper script in csh that runs the python. As part of the csh script it redirects stdout to a file for logging purposes.
We had a problem where this log file wouldn't be written to until the python process was stopped. This is due to the fact that python buffers stdout.
To get around this problem, you can run python with the -u command line option. See http://docs.python.org/using/cmdline.html#cmdoption-u for more details.