paul j3 <[email protected]> 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 not SUPPRESS:
defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
if action.option_strings or action.nargs in defaulting_nargs:
help += ' (default: %(default)s)'
return help
So it conditionally adds a '%(default)s' to the help string.
And in:
def _expand_help(self, action):
...
return self._get_help_string(action) % params
where 'params' is derived from the attributes of the 'Action' object.
I don't off hand see a clean way of suppressing this addition. We don't want
to add a parameter to 'add_argument' just for this.
As a user you can explicitly add the `%(default)s` to selected arguments, and
use the regular formatter. Admittedly it involves a bit more typing.
Or write your own version of the formatter subclass.
----------
nosy: +paul.j3
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32552>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com