python stdout to file does not respond in real time
You need to flush the buffer after printing.
import sysimport timeprint "begin"sys.stdout.flush()time.sleep(10)print "end"sys.stdout.flush()
Or in Python 3:
# This can also be done in Python 2.6+ with# from __future__ import print_functionimport timeprint("begin", flush=True)time.sleep(10)print("end", flush=True)