python how to capture all stdout and put it to a file code example Example: redirect python output to file $ python foo.py > file