No solution for "--verbose" (on stdout) output in Pythonds standard library?

c.buhtz at posteo.jp c.buhtz at posteo.jp
Wed Jan 4 08:53:23 EST 2023


Hello,

first I have to say that in my current and fresh humble opinion the
often seen "--verbose" switch in command line applications should
affect only the messages given to the users. This means messages on
"stdout". That is what this question is about.

The logging module is not an option because it works on stderr and is
not intended to offer messages for the user but just for the system and
its admins via logs (log-files, syslog, stderr redirection, ...).

Using logging handlers redirecting to stdout are considered as
workarounds by me and also not an option.

This is not only my opinion but also part of the Python documentation:
https://docs.python.org/3/howto/logging.html#when-to-use-logging

I'm so detailed here about that difference between stdout and stderr
because in the wild (e.g. on StackOverflow) you often find "use logging
log levels" as a solution for that problem, which IMHO isn't one.

Now the question:
From my research on the docs it seems there is no feature in the
standard library which could help me to implement "--verbose" or
multiple verbosity levels like "-vvv"?
I found some workarounds/hacks.
https://stackoverflow.com/q/5980042/4865723
But my experience with Python as a Swiss knife is that there is always
a standard solution for such basic and often reinvented things. I won't
believe that each Python developer writes its own verbose feature. ;)


More information about the Python-list mailing list