Skip to content

Commit 8c47ebf

Browse files
Add additional clarification on defaults
1 parent 0a32c69 commit 8c47ebf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Doc/library/argparse.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,10 @@ Parser defaults
21232123
>>> parser.parse_args(['736'])
21242124
Namespace(bar=42, baz='badger', foo=736)
21252125

2126-
Note that parser-level defaults always override argument-level defaults::
2126+
Note that defaults can be set at both the parser level using :meth:`set_defaults`
2127+
and at the argument level using :meth:`add_argument`. If both are provided for the
2128+
same attribute, the order of setting these defaults determines which one takes
2129+
precedence. The last default set for an attribute is the one that is used:
21272130

21282131
>>> parser = argparse.ArgumentParser()
21292132
>>> parser.add_argument('--foo', default='bar')

0 commit comments

Comments
 (0)