I would like to be able to change argparse default strings so the first word is capitalized. In lieu of that, I propose the attached patch to 2.7 which changes them in the source code.
Looks like "usage" is almost always lowercase in the programs I tried (ssh, svn, cat, etc.). So it probably wouldn't be a good idea to change the default. Seems like both this and issue 9694 need a better way to customize the text in argparse mesages. As a temporary workaround for the group names, you can try: parser._optionals.title = "Optional arguments" parser._positionals.title = "Positional arguments" I can't guarantee this will continue to work since it relies on internal details but at least it would work for the time being.
2.7 is closed to new features and I cannot see making a non-bug change in a maintenance release that could break something. Should this be closed in favor of #9694? (Or vice versa?). Perhaps one of the issues should be renamed something like "Improve argparse message customization".
... > Should this be closed in favor of #9694? (Or vice versa?). Perhaps one of the issues should be renamed something like "Improve argparse message customization". That sounds like a winner to me -Tom
I'm moving this over to Issue 11695, which proposes support for a usage/help message template. To customize the argument group names, the recommended approach is to create your own argument groups, and only put arguments there, e.g.: parser = argparse.ArgumentParser(add_help=False) flags = parser.add_argument_group('My Optional Arguments') flags.add_argument('-h', '--help', action='help') flags.add_argument('-v', action='version', version='1.3') Then you'll get just the "My Optional Arguments" heading.