Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow arguments to optionals to have different names #6

Closed
GoogleCodeExporter opened this issue Mar 23, 2015 · 1 comment
Closed

allow arguments to optionals to have different names #6

GoogleCodeExporter opened this issue Mar 23, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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.

Original issue reported on code.google.com by steven.b...@gmail.com on 28 Mar 2009 at 2:17

@GoogleCodeExporter
Copy link
Author

You can provide a tuple for the metavar= parameter as of r29.

Original comment by steven.b...@gmail.com on 13 Jul 2009 at 12:35

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant