how to redirect my stderr and stdout to same text file python code example Example: redirect python output to file $ python foo.py > file