summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-10-12 11:53:00 (GMT)
committerGitHub <noreply@github.com>2024-10-12 11:53:00 (GMT)
commit07c2d15977738165e9dc4248e7edda7c75ecc14b (patch)
tree23c48b1193ba31c20dea5bf3bac84da4c671b880 /Doc/library
parenta6c0c64de0ade400df7995f1e9480b6fc0f863aa (diff)
downloadcpython-07c2d15977738165e9dc4248e7edda7c75ecc14b.zip
cpython-07c2d15977738165e9dc4248e7edda7c75ecc14b.tar.gz
cpython-07c2d15977738165e9dc4248e7edda7c75ecc14b.tar.bz2
gh-85935: Explicitly document the case nargs=0 in argparse (GH-125302)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/argparse.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 19f8320..d58c75e 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -751,6 +751,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
@@ -878,6 +881,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: