https://github.com/python/cpython/commit/cd1828fcc3487d3e4fe5fe64b7171d77c3ba6635 commit: cd1828fcc3487d3e4fe5fe64b7171d77c3ba6635 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: savannahostrowski <[email protected]> date: 2026-06-09T15:44:53Z summary:
[3.14] GH-61082: Clarify nargs='*' positional default behavior (GH-150989) (#151169) GH-61082: Clarify nargs='*' positional default behavior (GH-150989) (cherry picked from commit bc37a227b2f481d0f260f9beae5229e8d432a0cc) 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 67d5cd87101b42..42f13142cf6151 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1048,6 +1048,10 @@ is used when no command-line argument was present:: >>> parser.parse_args([]) Namespace(foo=42) +Because ``nargs='*'`` gathers any supplied values into a list, an absent +positional argument yields an empty list (``[]``). Only a non-``None`` +*default* overrides this (so ``default=None`` still gives ``[]``). + 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``. _______________________________________________ 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]
