Skip to content

Commit

Permalink
pythonGH-87358: Add clarification about nargs and default argparse be…
Browse files Browse the repository at this point in the history
…haviour (python#124094)
  • Loading branch information
savannahostrowski authored Sep 24, 2024
1 parent 38a5beb commit 20ccda0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down

0 comments on commit 20ccda0

Please sign in to comment.