[issue7284] argparse - display version in usage by default

Steven Bethard report at bugs.python.org
Sat Mar 26 13:28:31 CET 2011


Steven Bethard <steven.bethard at gmail.com> added the comment:

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.

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

----------

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


More information about the Python-bugs-list mailing list