This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients elypter, paul.j3
Date 2018-04-24.19:05:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1524596746.85.0.682650639539.issue32552@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-04-24 19:05:46paul.j3setrecipients: + paul.j3, elypter
2018-04-24 19:05:46paul.j3setmessageid: <1524596746.85.0.682650639539.issue32552@psf.upfronthosting.co.za>
2018-04-24 19:05:46paul.j3linkissue32552 messages
2018-04-24 19:05:46paul.j3create