[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 20ccda000b)

Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-09-24 20:08:02 +02:00 committed by GitHub
parent 7c9bbaaaa3
commit b4b182a84d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1122,6 +1122,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::