From 7eb347baec004a8d626f8dd905fc4481313ff1a2 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 5 Jun 2026 14:07:28 -0700 Subject: [PATCH 1/4] Add clarification on name collision --- Doc/library/argparse.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index db5fae2006678a..7efd20e8edb639 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1369,6 +1369,10 @@ behavior:: >>> parser.parse_args('--foo XXX'.split()) Namespace(bar='XXX') +Multiple arguments may share the same ``dest``. By default the value from the +last such argument given on the command line wins; use ``action='append'`` to +collect values from all of them into a list instead. + .. versionchanged:: 3.15 Single-dash long option now takes precedence over short options. From cba04186ef1affba0087c605429560a95450be2f Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 5 Jun 2026 14:18:29 -0700 Subject: [PATCH 2/4] Rephrase --- Doc/library/argparse.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 7efd20e8edb639..3e4e687cf3c8d2 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1371,7 +1371,8 @@ behavior:: Multiple arguments may share the same ``dest``. By default the value from the last such argument given on the command line wins; use ``action='append'`` to -collect values from all of them into a list instead. +collect values from all of them into a list instead. (For conflicting *option +strings* rather than ``dest`` names, see conflict_handler_.) .. versionchanged:: 3.15 Single-dash long option now takes precedence over short options. @@ -1781,6 +1782,10 @@ Subcommands present, and when the ``b`` command is specified, only the ``foo`` and ``baz`` attributes are present. + If a subparser defines an argument with the same ``dest`` as the parent + parser, the subparser's value overwrites the parent's, so users should give + them distinct ``dest`` values to keep both. + Similarly, when a help message is requested from a subparser, only the help for that particular parser will be printed. The help message will not include parent parser or sibling parser messages. (A help message for each From 2e0cd04048b037361dde138a1fd58b8d0b0150f5 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 5 Jun 2026 14:18:40 -0700 Subject: [PATCH 3/4] Remove parens --- Doc/library/argparse.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 3e4e687cf3c8d2..f8ee163e488327 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1371,8 +1371,8 @@ behavior:: Multiple arguments may share the same ``dest``. By default the value from the last such argument given on the command line wins; use ``action='append'`` to -collect values from all of them into a list instead. (For conflicting *option -strings* rather than ``dest`` names, see conflict_handler_.) +collect values from all of them into a list instead. For conflicting *option +strings* rather than ``dest`` names, see conflict_handler_. .. versionchanged:: 3.15 Single-dash long option now takes precedence over short options. From 37aadf6e2caba7c9e9d232aab71ac4ead68efca0 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 5 Jun 2026 14:21:14 -0700 Subject: [PATCH 4/4] Remove ; --- Doc/library/argparse.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index f8ee163e488327..23538c22a8d6f6 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1369,8 +1369,8 @@ behavior:: >>> parser.parse_args('--foo XXX'.split()) Namespace(bar='XXX') -Multiple arguments may share the same ``dest``. By default the value from the -last such argument given on the command line wins; use ``action='append'`` to +Multiple arguments may share the same ``dest``. By default, the value from the +last such argument given on the command line wins. Use ``action='append'`` to collect values from all of them into a list instead. For conflicting *option strings* rather than ``dest`` names, see conflict_handler_.