Skip to content

Commit

Permalink
pythongh-85935: Excplicitly document the case nargs=0 in argparse
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Oct 11, 2024
1 parent 01fc3b3 commit 095c414
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,9 @@ how the command-line arguments should be handled. The supplied actions are:

.. versionadded:: 3.8

Only actions that consume command-line arguments (such as ``'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
Expand Down Expand Up @@ -858,6 +861,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 (such as
``'store_const'``) set ``nargs=0``.


.. _const:
Expand Down

0 comments on commit 095c414

Please sign in to comment.