https://github.com/python/cpython/commit/00087dc466e3711a2bb3b5e57cbb354302f9c60c
commit: 00087dc466e3711a2bb3b5e57cbb354302f9c60c
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: savannahostrowski <[email protected]>
date: 2025-11-05T22:52:22Z
summary:

[3.14] GH-108009: Add clarification of parser and argument defaults in argparse 
docs (GH-124154) (#141084)

GH-108009: Add clarification of parser and argument defaults in argparse docs 
(GH-124154)
(cherry picked from commit 95f6e1275b1c9de550d978cb2b4351cc4ed24fe4)

Co-authored-by: Savannah Ostrowski <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>

files:
M Doc/library/argparse.rst

diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 0ee921e15260c4..2dca4a71a5361a 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -2071,7 +2071,9 @@ Parser defaults
      >>> parser.parse_args(['736'])
      Namespace(bar=42, baz='badger', foo=736)
 
-   Note that parser-level defaults always override argument-level defaults::
+   Note that defaults can be set at both the parser level using 
:meth:`set_defaults`
+   and at the argument level using :meth:`add_argument`. If both are called 
for the
+   same argument, the last default set for an argument is used::
 
      >>> parser = argparse.ArgumentParser()
      >>> parser.add_argument('--foo', default='bar')

_______________________________________________
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]

Reply via email to