New submission from Benjamin Giesers:
It would be nice to propagate the formatter_class defined in
argparse.ArgumentParser() to added SubParsers by default. Currently one has to
define the formatter_class for each subparser again and again.
Example:
parser = argparse.ArgumentParser(description='property',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
subparsers = parser.add_subparsers(help='sub-command help')
pcar = subparsers.add_parser('car', help='add car',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
pcar.add_argument('--color', help='color of car', default='red')
pyacht = subparsers.add_parser('yacht', help='add yacht',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
pyacht.add_argument('--length', help='length of yacht [m]', default=12.5)
----------
components: Library (Lib)
messages: 274114
nosy: Benjamin Giesers
priority: normal
severity: normal
status: open
title: argparse: default propagation of formatter_class from ArgumentParser()
to SubParsers
type: enhancement
versions: Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27927>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com