]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-87358: Add clarification about nargs and default argparse behaviour (#124094)
authorSavannah Ostrowski <savannahostrowski@gmail.com>
Tue, 24 Sep 2024 16:30:01 +0000 (09:30 -0700)
committerGitHub <noreply@github.com>
Tue, 24 Sep 2024 16:30:01 +0000 (19:30 +0300)
Doc/library/argparse.rst

index f22aeb8c13c605369caaac24ccf104ee2fbd01d5..53ecc97d5659f4382f6c88806c1a3a36c71c884e 100644 (file)
@@ -1123,6 +1123,9 @@ is used when no command-line argument was present::
    >>> parser.parse_args([])
    Namespace(foo=42)
 
+For required_ arguments, the ``default`` value is ignored. For example, this
+applies to positional arguments with nargs_ values other than ``?`` or ``*``,
+or optional arguments marked as ``required=True``.
 
 Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if the
 command-line argument was not present::