FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-59633: Clarify dest collisions in argparse docs by savannahostrowski · Pull Request #150987 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 10 additions & 0 deletions Doc/library/argparse.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,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_.

Comment thread
savannahostrowski marked this conversation as resolved.
.. versionchanged:: 3.15
Single-dash long option now takes precedence over short options.

Expand Down Expand Up @@ -1777,6 +1782,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
Expand Down
Loading

Back | FazBrowse Home | New Git URL