问题描述
为什么 Guido(或其他任何人)决定让 python --version
打印到 stderr 而不是 stdout?只是好奇什么用例使标准错误比标准输出更合适.
Why did Guido (or whoever else) decide to make python --version
print to stderr rather than stdout? Just curious what the use case is that makes standard error more appropriate than standard out.
推荐答案
Python 3.4 被修改为输出到 stdout
,这是预期的行为.这在此处列为 Python 错误:http://bugs.python.org/issue18338.对错误报告的评论表明,虽然 stdout
是合理的选择,但它会破坏向后兼容性.Python 2.7.9 基本上没有变化,因为它非常依赖它.
Python 3.4 was modified to output to stdout
, which is the expected behavior. This is listed as a bug with Python here: http://bugs.python.org/issue18338. The comments on the bug report indicate that while stdout
is the reasonable choice, it would break backward compatibility. Python 2.7.9 is largely unchanged, because so much relies on it.
希望有帮助!
这篇关于为什么python将版本信息打印到stderr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!