From: Savannah Ostrowski Date: Tue, 24 Sep 2024 16:30:01 +0000 (-0700) Subject: GH-87358: Add clarification about nargs and default argparse behaviour (#124094) X-Git-Tag: v3.14.0a1~369 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20ccda000b5f8365d5f864fd07876804157c2378;p=thirdparty%2FPython%2Fcpython.git GH-87358: Add clarification about nargs and default argparse behaviour (#124094) --- diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index f22aeb8c13c6..53ecc97d5659 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -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::