Currently, no matter how many arguments an optional takes, they're all named the same::
>>> parser = argparse.ArgumentParser(prog='PROG', add_help=False) >>> parser.add_argument('-c', nargs=2, metavar='X') >>> parser.print_help() usage: PROG [-c X X]
optional arguments: -c X X
It would be nice to have multiple names sometimes (e.g. "X Y" instead of "X X" above).
Perhaps this could be achieved by allowing metavar to be a sequence as well as a string. I'm a little nervous though about the typecheck necessary to distinguish between strings and other sequences, and the fact that you'd need to check that the length of the sequence and the nargs value matched.
Comment #1
Posted on Jul 13, 2009 by Grumpy RabbitYou can provide a tuple for the metavar= parameter as of r29.
Status: Fixed
Labels:
Type-Enhancement
Priority-Medium