paul j3 added the comment:
https://bugs.python.org/issue28742
argparse.ArgumentDefaultsHelpFormatter sometimes provides inaccurate
documentation of defaults, so they should be overrideable
is asking for something similar - the ability to override the automatic
`%(default)s` in certain cases.
paul j3 added the comment:
An alternative to customizing a HelpFormatter is to write your own utility
`add_argument` function, e.g.
def my_add_argument(parser, *args, add_default=True, **kwargs):
if add_default:
help = kwargs.get('help','')
help += ' (default: %(default)s)
paul j3 added the comment:
This subclass makes are one method change:
from:
def _get_help_string(self, action):
return action.help
to:
def _get_help_string(self, action):
help = action.help
if '%(default)' not in action.help:
if action.default is n
New submission from elypter :
If you use formatter_class=argparse.ArgumentDefaultsHelpFormatter in the
constructor then the defaults that you include in arguments get automatically
added to the help text. this looks great for int and Strings but not for files.
example:
-suffixes [SUFFIXES]