[New-bugs-announce] [issue27927] argparse: default propagation of formatter_class from ArgumentParser() to SubParsers
Benjamin Giesers
report at bugs.python.org
Thu Sep 1 06:06:59 EDT 2016
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 <report at bugs.python.org>
<http://bugs.python.org/issue27927>
_______________________________________
More information about the New-bugs-announce
mailing list