https://github.com/python/cpython/commit/b4b182a84d0b349622c089c99cc3ab30cd485269 commit: b4b182a84d0b349622c089c99cc3ab30cd485269 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: Yhg1s <[email protected]> date: 2024-09-24T11:08:02-07:00 summary:
[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 20ccda000b5f8365d5f864fd07876804157c2378) Co-authored-by: Savannah Ostrowski <[email protected]> files: M Doc/library/argparse.rst diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index c4e2dbcac2156c..5f7cecd2cad18e 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -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:: _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
