Python Forum
can i merge stderr and stdout? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: can i merge stderr and stdout? (/thread-21411.html)



can i merge stderr and stdout? - Skaperen - Sep-29-2019

can i merge stderr and stdout? is this a way to do it?
sys.stderr.flush()
sys.stdout.flush()
sys.stderr=sys.stdout
i also want to have them buffered together so there is no chance of their output being in different order. but the primary goal is to get all output to stdout (or to stderr in other cases).

when i do shell redirection to a common descriptor, output order can be mixed in the wrong order due to stdout buffering delaying output.


RE: can i merge stderr and stdout? - Larz60+ - Sep-29-2019

I think:
import sys

sys.stdout = open('filename', 'w')
sys.stderr = sys.stdout
You'll have to try it.


RE: can i merge stderr and stdout? - Skaperen - Sep-29-2019

it writes to the file, so it might work that way.