[issue7284] argparse - display version in usage by default

anatoly techtonik report at bugs.python.org
Sat Mar 26 16:31:11 CET 2011


anatoly techtonik <techtonik at gmail.com> added the comment:

On Sat, Mar 26, 2011 at 2:28 PM, Steven Bethard <report at bugs.python.org> wrote:
>
> I'm not sure about the usage_template approach - seems like it might be hard to make it work, while still supporting formatter_class. (Though maybe it's not so bad since the formatter class methods are all considered implementation details.) I'm open to patches though if you're willing to provide one.

The main point was to cut extra arguments in constructor that are used
solely for formatting the result, but it is too late to do any changes
now.

> In the meantime, a simple approach that will work is to override format_help():
>
> class MyArgumentParser(argparse.ArgumentParser):
>    def format_help(self):
>        help = super(MyArgumentParser, self).format_help()
>        return headline + '\n' + help

Thanks. I'll try this one next time or think about the patch. ;)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7284>
_______________________________________


More information about the Python-bugs-list mailing list