8000 [3.13] GH-87358: Add clarification about nargs and default argparse b… · python/cpython@b4b182a · GitHub
[go: up one dir, main page]

Skip to content

Commit b4b182a

Browse files
[3.13] GH-87358: Add clarification about nargs and default argparse behaviour (GH-124094) (#124440)
GH-87358: Add clarification about nargs and default argparse behaviour (GH-124094) (cherry picked from commit 20ccda0) Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
1 parent 7c9bbaa commit b4b182a

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

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

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

0 commit comments

Comments
 (0)
0