https://github.com/python/cpython/commit/ba8d0e37e77ed7a53e573f453d434a621d276ce9 commit: ba8d0e37e77ed7a53e573f453d434a621d276ce9 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: savannahostrowski <[email protected]> date: 2026-06-09T17:15:41Z summary:
[3.15] GH-59633: Clarify dest collisions in argparse docs (GH-150987) (#151188) GH-59633: Clarify dest collisions in argparse docs (GH-150987) (cherry picked from commit 82cb7d4bf62041b75a08628baa1f9fe761fd6a79) Co-authored-by: Savannah Ostrowski <[email protected]> files: M Doc/library/argparse.rst diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 4c588d447a9a7c..e4a5f4d109b499 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1372,6 +1372,11 @@ 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. For conflicting *option +strings* rather than ``dest`` names, see conflict_handler_. + .. versionchanged:: 3.15 Single-dash long option now takes precedence over short options. @@ -1780,6 +1785,11 @@ 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 two share a single namespace attribute, so the parent's value + won't be retained. 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 _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
