1

Using python 2.7 I am calling an external library function and I want to print all the logs/prints that this function generates to a file. I would like to update the file with the logs as they happen. I am using ipython notebook so if there is an easier way which is notebook specific I will be ok with that too.

ajkl
  • 1,016
  • 1
  • 7
  • 27

1 Answers1

1

It's probably better to perform the redirection in your shell, not from within the python code.

From a typical Unix command line, you can use the tee command:

python program.py | tee logfile
John Gordon
  • 29,573
  • 7
  • 33
  • 58