This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients Martin.d'Anjou, benschmaus, bethard, docs@python, eric.araujo, eric.smith, martin.panter, mburger, paul.j3, r.david.murray, rhettinger, terry.reedy, tshepang
Date 2014-02-14.07:32:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1392363132.73.0.554537935133.issue9694@psf.upfronthosting.co.za>
In-reply-to
Content
Here's another possible solution: add a `help_groups` parameter to ArgumentParser.  It is a list of base argument group names.  `parser.add_argument(...)' places the action in one of those groups.

This is a generalization of the current code which creates two groups titled 'positional arguments' and 'optional arguments', and assigns actions based on 'optional strings' (e.g. '-f','--foo').

'help_groups' could have 1, 2, or 3 items.  

1 - just one argument group

2 - the current postional/optional split, but with user chosen names

3 - a 'positional', 'required', and 'optional' split.  

A 4 way split that distinguishes splits positionals between those that allow 0 values and 1 or more, is possible, but probably not that useful.

The changes are in the ArgumentParser.__init__ and _add_action methods.

'subparsers' do not inherit this parameter.  I have not explored how it plays out with 'parents'. 'test_argparse.py' runs fine.
History
Date User Action Args
2014-02-14 07:32:12paul.j3setrecipients: + paul.j3, rhettinger, terry.reedy, bethard, eric.smith, eric.araujo, r.david.murray, docs@python, benschmaus, tshepang, martin.panter, mburger, Martin.d'Anjou
2014-02-14 07:32:12paul.j3setmessageid: <1392363132.73.0.554537935133.issue9694@psf.upfronthosting.co.za>
2014-02-14 07:32:12paul.j3linkissue9694 messages
2014-02-14 07:32:12paul.j3create