Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can i merge stderr and stdout?
#1
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
I think:
import sys

sys.stdout = open('filename', 'w')
sys.stderr = sys.stdout
You'll have to try it.
Reply
#3
it writes to the file, so it might work that way.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  flask How to output stderr and exceptions to log file umen 4 4,771 Jun-20-2020, 06:11 AM
Last Post: umen
  Log WSGI directly to stdout ThomasT 4 3,862 Jan-24-2019, 10:17 AM
Last Post: ThomasT

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020