mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[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:
parent
7c9bbaaaa3
commit
b4b182a84d
1 changed files with 3 additions and 0 deletions
|
@ -1122,6 +1122,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::
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue