Python argparse help option in a mutually_exclusive_group

Viewed 63

The argparse module for Python 2.7 includes a command line help option, that by default prints a usage message whenever -h or --help is present in the command line options. By default, the help option can be passed in with any other command line options. For example:

script.py [-h] [-opt1 arg1 | -opt2 arg2]

If the -h optional argument exists, all other args are ignored and the help message is printed.

Is there a way to change this behavior so that -h has to be used alone, like can be done with any other optional arg by placing it within a mutually_exclusive_group?

0 Answers
Related