Using the same option multiple times in Python’s argparse

Here’s a parser that handles a repeated 2 argument optional – with names defined in the metavar: parser=argparse.ArgumentParser() parser.add_argument(‘-i’,’–input’,action=’append’,nargs=2, metavar=(‘url’,’name’),help=’help:’) In [295]: parser.print_help() usage: ipython2.7 [-h] [-i url name] optional arguments: -h, –help show this help message and exit -i url name, –input url name help: In [296]: parser.parse_args(‘-i one two -i three four’.split()) Out[296]: … Read more