A tough solution is to add version text to your usage string. This is not ideal (note the additional usage text), but its beginning
In [64]: parser=argparse.ArgumentParser(description='description')
The order of the components in help is determined by the ArgumentParser.format_help method (quoted from the argparse.py file):
def format_help(self): formatter = self._get_formatter()
I can imagine how to write a custom method that adds your version information, for example.
def format_help(self): formatter = self._get_formatter()
In ipython this function works:
In [74]: def format_help(parser): formatter=parser._get_formatter() formatter.add_text('version 1.0.1') formatter.add_usage(parser.usage, parser._actions, parser._mutually_exclusive_groups) formatter.add_text(parser.description) return formatter.format_help() In [75]: print format_help(parser) version 1.0.1 usage: ipython [-h] description
hpaulj
source share