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
  • 669,327
  • 51
  • 454
  • 560
user1357015
  • 10,429
  • 19
  • 62
  • 104

0 Answers0