Skip to content

Commit 00087dc

Browse files
miss-islingtonsavannahostrowskiCAM-Gerlach
authored
[3.14] pythonGH-108009: Add clarification of parser and argument defaults in argparse docs (pythonGH-124154) (python#141084)
pythonGH-108009: Add clarification of parser and argument defaults in argparse docs (pythonGH-124154) (cherry picked from commit 95f6e12) Co-authored-by: Savannah Ostrowski <[email protected]> Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent 5561837 commit 00087dc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Doc/library/argparse.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,9 @@ Parser defaults
20712071
>>> parser.parse_args(['736'])
20722072
Namespace(bar=42, baz='badger', foo=736)
20732073

2074-
Note that parser-level defaults always override argument-level defaults::
2074+
Note that defaults can be set at both the parser level using :meth:`set_defaults`
2075+
and at the argument level using :meth:`add_argument`. If both are called for the
2076+
same argument, the last default set for an argument is used::
20752077

20762078
>>> parser = argparse.ArgumentParser()
20772079
>>> parser.add_argument('--foo', default='bar')

0 commit comments

Comments
 (0)