Why does python output version information to stderr?

Why did Guido (or someone else) decide to make python --version print to stderr and not to stdout? It's just curious that a use case is used that makes the standard error more suitable than the standard error.

+8
python
source share
2 answers

Python 3.4 has been changed to output to stdout , which is the expected behavior. This is indicated as a bug with Python here: http://bugs.python.org/issue18338 . Comments on the bug report indicate that while stdout is a smart choice, it will break compatibility. Python 2.7.9 has not changed much because it relies so much.

Hope this helps!

+10
source share

Many programs just use stdout and do not care, but I would prefer stderr in principle. In short, I believe that stdout is for the product of successful execution of the program, and stderr is for any messages intended for the user. The calculated values ​​go to stdout , while errors, stack traces, help, version, and usage messages are for the user and should go to stderr .

I use this question to decide which output stream is appropriate: Is this message for the consumer of the main product of this program (whether it is a user user or another program or something else) or is it strictly for the person of this program?

In addition, it looks like Java uses stderr for version messages, as well: Why does java -version go into stderr?

+1
source share

All Articles