I’d like to display argparse help for my options the same way the default -h,--help and -v,--version are, without the ALLCAPS text after the option, or at least without the duplicated CAPS.
import argparse
p = argparse.ArgumentParser("a foo bar dustup")
p.add_argument('-i', '--ini', help="use alternate ini file")
print '\n', p.parse_args()
This is what I currently get with python foobar.py -h:
usage: a foo bar dustup [-h] [-i INI]
optional arguments:
-h, --help show this help message and exit
-i INI, --ini INI use alternate ini
And this is what I want:
usage: a foo bar dustup [-h] [-i INI]
optional arguments:
-h, --help show this help message and exit
-i, --ini INI use alternate ini
This would be acceptable too:
-i, --ini use alternate ini
I’m using python 2.7.
You could customize
usageand assignmetavarto an empty string:Output