[issue11174] add argparse formatting option to display type names for metavar

Steven Bethard report at bugs.python.org
Sat Mar 26 13:16:43 CET 2011


Steven Bethard <steven.bethard at gmail.com> added the comment:

Sorry about such a slow response on this. Thanks for the patch!

I think rather than adding an ArgumentParser constructor parameter though, we should add a new formatter class. The attached patch allows you to write:

   >>> parser = argparse.ArgumentParser(
   ...     prog='PROG',
   ...     formatter_class=argparse.MetavarTypeHelpFormatter)
   >>> parser.add_argument('--foo', type=int)
   >>> parser.add_argument('bar', type=float)
   >>> parser.print_help()
   usage: PROG [-h] [--foo int] float

   positional arguments:
     float

   optional arguments:
     -h, --help  show this help message and exit
     --foo int

What do you think?

----------
Added file: http://bugs.python.org/file21407/MetavarTypeHelpFormatter.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11174>
_______________________________________


More information about the Python-bugs-list mailing list