GH-87358: Add clarification about nargs and default argparse behaviour (#124094)

This commit is contained in:
Savannah Ostrowski 2024-09-24 09:30:01 -07:00 committed by GitHub
parent 38a5beb12a
commit 20ccda000b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -1123,6 +1123,9 @@ is used when no command-line argument was present::
>>> parser.parse_args([]) >>> parser.parse_args([])
Namespace(foo=42) 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 Providing ``default=argparse.SUPPRESS`` causes no attribute to be added if the
command-line argument was not present:: command-line argument was not present::