[Python] Verbose level with argparse and multiple -v options

Discussão em 'Python' iniciado por Stack, Janeiro 31, 2025.

  1. Stack

    Stack Membro Participativo

    I'd like to be able to specify different verbose level, by adding more -v options to the command line. For example:

    $ myprogram.py
    $ myprogram.py -v
    $ myprogram.py -vv
    $ myprogram.py -v -v -v


    would lead to verbose=0, verbose=1, verbose=2, and verbose=3 respectively. How can I achieve that using argparse?

    Optionally, it could be great to also be able to specify it like

    $ myprogram -v 2

    Continue reading...

Compartilhe esta Página