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.

classification
Title: argparse: title and description for mutually exclusive arg groups
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: paul.j3, rhettinger, shihai1991, signing_agreement
Priority: normal Keywords:

Created on 2020-01-02 20:07 by signing_agreement, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg359217 - (view) Author: (signing_agreement) * Date: 2020-01-02 20:07
add_mutually_exclusive_group has one flag, required=False. Yet, regardless of specifying required=True, the help message calls the group "optional arguments". It would be nice to be able to add title and description for mutually exclusive groups.

Right now, programmers can only do changes via
parser._action_groups[1].title = 'mutually exclusive required arguments'
msg359345 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2020-01-05 14:14
Do you have user case for it?

_ArgumentGroup have the `title` attribute, so  _MutuallyExclusiveGroup add same attribute is not a big probleam(if user really need it).
msg360232 - (view) Author: paul j3 (paul.j3) * (Python triager) Date: 2020-01-18 04:31
A mutually_exclusive_group is not an argument_group.  It affects parsing and the usage, but does nothing in the help lines.

A mutually_exclusive_group may be nested in an argument_group if you want another group title.  

     g1 = parser.add_argument_group('My Required Group')
     g2 = g1.add_mutually_exclusive_group(....)

Groups are not really designed for nesting, but this is one case the nesting works and is useful.  Nesting, to the extent it works, is simple a consequence of inheritance from the _Argument_Container class.

Changing the title of the default action group is always an option, mutually_exclusive or not.  Other bug/issues have suggest changing that title at creation time, or giving the user a choice (maybe even defining 3 default groups).  But for now we recommend creating your own argument group(s) if you don't like the titles of the default one(s).

So no, I don't think anything should be changed simply because a mutually_exclusive group is marked as required.
msg360234 - (view) Author: paul j3 (paul.j3) * (Python triager) Date: 2020-01-18 05:00
https://bugs.python.org/issue9694

is the original issue about the titles of the base argument groups.
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83378
2020-01-18 05:00:31paul.j3setstatus: open -> closed
resolution: duplicate
messages: + msg360234

stage: resolved
2020-01-18 04:31:37paul.j3setnosy: + paul.j3
messages: + msg360232
2020-01-05 14:14:47shihai1991setnosy: + shihai1991
messages: + msg359345
2020-01-04 07:01:48terry.reedysetnosy: + rhettinger

title: Support the title and description arguments for mutually exclusive argument groups -> argparse: title and description for mutually exclusive arg groups
2020-01-02 20:07:45signing_agreementcreate