Skip to content

Commit 20ccda0

Browse files
GH-87358: Add clarification about nargs and default argparse behaviour (#124094)
1 parent 38a5beb commit 20ccda0

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
@@ -1123,6 +1123,9 @@ is used when no command-line argument was present::
11231123
>>> parser.parse_args([])
11241124
Namespace(foo=42)
11251125

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

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

0 commit comments

Comments
 (0)