import sys
if __name__ == '__main__':
sys.stdout.write("STDOUT\n")
sys.stderr.write("STDERR\n")
Could you explain why when I write to stderr I see STDERR output on the stdout? I supposed only STDOUT should be visible in the terminal.
$ python stdout_stdin.py
STDOUT
STDERR
I supposed only STDOUT should be visible in the terminal.
Incorrect. stderr is a separate file descriptor, but it's still connected to the same tty as stdout by default.