how to redirect all the output to a file in python code example Example: redirect python output to file $ python foo.py > file