Skip to content

Commit

Permalink
[3.12] GH-87358: Add clarification about nargs and default argparse b…
Browse files Browse the repository at this point in the history
…ehaviour (GH-124094) (#124441)

Co-authored-by: Savannah Ostrowski <[email protected]>
  • Loading branch information
miss-islington and savannahostrowski authored Sep 24, 2024
1 parent 0c36c37 commit 10cf0b8
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 @@ -1121,6 +1121,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 10cf0b8

Please sign in to comment.