0

I'm trying to redirect the output of a python script to a file. I have run:

C:\>python c:\python_script.py > a.txt 2>&1

Found here but output is only written once the process completes or is killed. Is there a way to have the redirection write to file as output is written to stdout & stderr?

Harry Johnston
  • 33,445
  • 6
  • 56
  • 142
Trent
  • 2,176
  • 2
  • 31
  • 47
  • Not unless Python itself provides such a mechanism. (Question retagged in the hopes of attracting the attention of a Python expert.) – Harry Johnston Mar 22 '16 at 22:48
  • Why not use Python's logging module in the `python_script`? Then you can log anywhere in the script in real time – Mike Driscoll Mar 23 '16 at 15:59
  • That's an option, but a Windows solution would be ideal (eg: what if I didn't have the Python source, or if it was a different program?) – Trent Mar 24 '16 at 02:36

0 Answers0