[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group
paul j3
report at bugs.python.org
Fri Feb 19 00:54:42 EST 2021
paul j3 <ajipanca at gmail.com> added the comment:
The mutually exclusive arguments are displayed with in the argument group, at least in my testing. From a copy-n-paste of your example:
In [8]: parser.print_help()
usage: ipython3 [-h]
[--from-args FROM_ARGS | --from-files FROM_FILES | --from-stdin FROM_STDIN]
[-0 0]
optional arguments:
-h, --help show this help message and exit
INPUT OPTIONS:
--from-args FROM_ARGS
--from-files FROM_FILES
--from-stdin FROM_STDIN
-0 0 null delimited pathnames
I've had occasion to note that this is the only kind of group nesting that works (or makes sense).
In add_container_actions, there is a comment:
# add container's mutually exclusive groups
# NOTE: if add_mutually_exclusive_group ever gains title= and
# description= then this code will need to be expanded as above
So the original developer envisioned giving a mutually exclusive group a formatting role, but with this nesting this isn't needed (that I can tell). But I don't think this has been documented.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43259>
_______________________________________
More information about the Python-bugs-list
mailing list