Re: argparse — adding a --version flag in the face of positional args
Skip Montanaro
skip.montanaro at gmail.com
Sun Nov 27 22:33:43 EST 2022
>
> ummm, hate to say this, but have you checked the documentation? this
> case is supported using an action named 'version' without doing very much.
>
Thanks, Mats.
I actually searched all over the argparse docs. (There's a lot to digest.
Honestly, if I wasn't attempting to be sort of up-to-date I'd just continue
using getopt.) It never occurred to me that "version" would be special, so
I didn't specifically search for it, or realize there would be a specific
action devoted to it. I knew (the default) "help" was special, so I focused
my search for it. Obviously, "--help" is a pretty bad search term.
Skip
>
More information about the Python-list
mailing list