paul j3 added the comment:

This ArgumentDefaultHelpFormatter issue should probably be raised in its own 
issue.  It applies to 'required' optionals, but any patch would be independent 
of the issues discussed here.

This class defines a method that adds the '%(default)' string to the help in 
certain situations.  It already skips required positionals.  So adding a test 
for 'action.required' should be easy.

    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

There are 2 easy user fixes.

- a custom HelpFormatter class that implements this fix.  

- 'default=argparse.SUPPRESS' for arguments where you do not want to see the 
default.  This SUPPRESS is checked else where in the code, but for a required 
argument I don't think that matters (but it needs testing).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9694>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to