0

I'm trying to flush all of std out to a python file via:

sys.stdout = open('myfile.txt', 'w')
print("Starting work")
sys.stdout.flush()
whole bunch of stuff with prints and sys.stdout.flush() mixed in
print("ending work")
sys.stdout.flush()

Unfortunately, nothing prints until the script terminates. The file size remains 0 kb. I am doing this on a windows machine if that helps with python 2.7

Thank you!

Barmar
  • 741,623
  • 53
  • 500
  • 612
user1357015
  • 11,168
  • 22
  • 66
  • 111

0 Answers0