What should go to stdout/stderr and why Python logging write everything to stderr?
c.buhtz at posteo.jp
c.buhtz at posteo.jp
Tue Jan 3 10:35:23 EST 2023
Hello,
this posting isn't about asking for a technical solution. My intention
is to understand the design decision Python's core developers made in
context of that topic.
The logging module write everything to stderr no matter which logging
level is used.
The argparse module does it more differentiated. If arguments are
mandatory but none are given then argparse produce a short version of
the usage info; on stderr. If the user request the usage info via "-h"
it goes to stdout. This is the behavior I would expect.
Why does logging behave different? DEBUG and INFO imho should go to
stdout not stderr.
Of course I could modify the handlers etc. to workaround this. But I
assume that there was something in mind of the Python developers when
they decided that.
My goal is not to divide between the use of print() or logging.info()
in my own code. This would mess up a lot.
More information about the Python-list
mailing list