From 2e1470f441897f54b5ef6e8f98a8c66904176cc0 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sun, 24 Nov 2019 16:48:52 +0100 Subject: [PATCH] argparse: improve mutually exclusive groups The current wording "Note that currently mutually exclusive argument groups do not support the title and description arguments" implies that in the future they will. However, that doesn't seem needed, as one can simply wrap the mutually exclusive group into an argument with with the desired title/description. --- Doc/library/argparse.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index f8e39189686..42d5c81ec3e 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1915,9 +1915,13 @@ Mutual exclusion usage: PROG [-h] (--foo | --bar) PROG: error: one of the arguments --foo --bar is required - Note that currently mutually exclusive argument groups do not support the + Note that mutually exclusive argument groups do not support the *title* and *description* arguments of - :meth:`~ArgumentParser.add_argument_group`. + :meth:`~ArgumentParser.add_argument_group`. If you want a mutually exclusive group + to be formatted separately, wrap it via an argument group: + + >>> parser = argparse.ArgumentParser(prog='PROG') + >>> group = parser.add_argument_group('group').add_mutually_exclusive_group() Parser defaults