I have a python script that currently outputs a bunch of text to stdout (the terminal). It looks something like:
print "ABC"
print "CD"
print "QR"
methodCallToOtherCodeThatAlsoPrints()
# A bunch of other print lines...
Right now all of this output just goes to stdout; however, I want the output to be written to a file in addition to writing to the terminal. What is the best way to do this? Ideally I don't want to have to change all of the print statements (to another method call for instance), and I don't have access to some of the code is called to do the printing.
I was thinking, is there someway I can redirect print output to both stdout AND a file?