paul j3 <ajipa...@gmail.com> 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)'
        kwargs['help'] = help
    return parser.add_argument(*args, **kwargs)

which could be used as

my_add_argument(parser, '-g', help='bar help', default='other', 
add_default=False)

There are some refinements to the _get_help_string() that I showed earlier, 
such as only adding the '%s' to actions where default makes sense (optionals 
and a subset positionals).  One could also skip it if the default is the 
default default None, etc.

One way or other the user can already control whether the help line shows the 
default.  ArgumentDefaultsHelpFormatter just automates this for a straight 
forward parser.  

I'm going to close this issue since it isn't really needed (and no one has 
proposed a clever patch).

----------
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

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

Reply via email to