Skip to content

Commit f671739

Browse files
miss-islingtonsavannahostrowskiCAM-Gerlach
authored
[3.13] pythonGH-108009: Add clarification of parser and argument defaults in argparse docs (pythonGH-124154) (python#141085)
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 fc059db commit f671739

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
@@ -1965,7 +1965,9 @@ Parser defaults
19651965
>>> parser.parse_args(['736'])
19661966
Namespace(bar=42, baz='badger', foo=736)
19671967

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

19701972
>>> parser = argparse.ArgumentParser()
19711973
>>> parser.add_argument('--foo', default='bar')

0 commit comments

Comments
 (0)