https://github.com/python/cpython/commit/e01a1784dbfe366cd2d5e22bba8b964107651bf0
commit: e01a1784dbfe366cd2d5e22bba8b964107651bf0
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-10-12T16:02:14+03:00
summary:

[3.12] gh-85935: Explicitly document the case nargs=0 in argparse (GH-125302) 
(GH-125358)

(cherry picked from commit 07c2d15977738165e9dc4248e7edda7c75ecc14b)

Co-authored-by: Serhiy Storchaka <[email protected]>

files:
M Doc/library/argparse.rst

diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index bcbdb0516bba93..a1f08ea272934f 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -726,6 +726,9 @@ how the command-line arguments should be handled. The 
supplied actions are:
 
   .. versionadded:: 3.8
 
+Only actions that consume command-line arguments (e.g. ``'store'``,
+``'append'`` or ``'extend'``) can be used with positional arguments.
+
 You may also specify an arbitrary action by passing an Action subclass or
 other object that implements the same interface. The ``BooleanOptionalAction``
 is available in ``argparse`` and adds support for boolean actions such as
@@ -853,6 +856,8 @@ See also :ref:`specifying-ambiguous-arguments`. The 
supported values are:
 If the ``nargs`` keyword argument is not provided, the number of arguments 
consumed
 is determined by the action_.  Generally this means a single command-line 
argument
 will be consumed and a single item (not a list) will be produced.
+Actions that do not consume command-line arguments (e.g.
+``'store_const'``) set ``nargs=0``.
 
 
 .. _const:

_______________________________________________
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]

Reply via email to