I am using python 2.7, and currently, I have a python code that prints to screen. I have been piping the output from the python code to a file by using >> command in linux until now. I would like to know if there is a simple method of printing out the output to a file without having to change every print function. Is this possible in python?
def print1():
print "something1"
def print2():
print "something2"
...
def printN():
print "somethingN"
def main():
print1()
print2()
...
printN()
//I would like all the output to be in a file