Sometimes its helpful to separate the help and version options (which
provide script information) from those used in running the script
normally.
I can create a custom argument group that includes the help and
version options as follows:
p = argparse.ArgumentParser(description=script_description,
add_help=False)
gh = p.add_argument_group('program help')
gh.add_argument('-h', '--help', action='help', help='show this help
message and exit')
gh.add_argument('--version', action='version', version=script_version)
But the docs (the python2.7 docs at least) did not show the
action='help' possibility, so I wanted to confirm it was supported/
official. Also, if this is indeed a recommended way to do what I was
trying to do, it seems that the default help text for the help option
is not included (I needed to supply it as illustrated above).
Yes, it's supported - the fact that it's not documented is a bug:
http://bugs.python.org/issue10772
> Also, if this is indeed a recommended way to do what I was
> trying to do, it seems that the default help text for the help option
> is not included (I needed to supply it as illustrated above).
Yeah, at the moment, you have to specify it again. Feel free to file a
feature request at bugs.python.org - it should be easy to set the
default help for _HelpAction to _('show this help message and exit')
and that's probably what most people would want.
Steve
--
Where did you get that preposterous hypothesis?
Did Steve tell you that?
--- The Hiphopopotamus