Python Forum

Full Version: combining stdout and stderr
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i want to combine stdout and stderr on the same output so both can go over a single pipe. the buffering of stdout can mess up the line ordering. i don't want to solve that be eliminating buffering. i want output to either to be buffered in a common buffer. it seemed to work when i did
    import sys
    ...
    sys.stdout.flush() # not necessary if before any output
    sys.stderr.flush() # i have hit cases where it was buffered
    sys.stderr = sys.stdout
    ...
is there a more appropriate way to do this?
Skaperen Wrote:is there a more appropriate way to do this?
I don't see one. The code looks very pythonic.