Skip to content

Commit 10cf0b8

Browse files
[3.12] GH-87358: Add clarification about nargs and default argparse behaviour (GH-124094) (#124441)
Co-authored-by: Savannah Ostrowski <[email protected]>
1 parent 0c36c37 commit 10cf0b8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Doc/library/argparse.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,9 @@ is used when no command-line argument was present::
11211121
>>> parser.parse_args([])
11221122
Namespace(foo=42)
11231123

1124+
For required_ arguments, the ``default`` value is ignored. For example, this
1125+
applies to positional arguments with nargs_ values other than ``?`` or ``*``,
1126+
or optional arguments marked as ``required=True``.
11241127

11251128
Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if the
11261129
command-line argument was not present::

0 commit comments

Comments
 (0)