how to redirect my stdouts in python to a text file code example Example: redirect python output to file $ python foo.py > file