mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.13] gh-85935: Explicitly document the case nargs=0 in argparse (GH-125302) (GH-125357)
(cherry picked from commit 07c2d15977
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
33c41360c8
commit
0542645354
1 changed files with 5 additions and 0 deletions
|
@ -728,6 +728,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
|
||||
|
@ -855,6 +858,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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue