8000 doc(argparse): fix description of BooleanOptionalAction · python/cpython@e4b9fd5 · GitHub
[go: up one dir, main page]

Skip to content

Commit e4b9fd5

Browse files
committed
doc(argparse): fix description of BooleanOptionalAction
1 parent a87f3e0 commit e4b9fd5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Doc/library/argparse.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -839,15 +839,17 @@ how the command-line arguments should be handled. The supplied actions are:
839839
>>> parser.parse_args(['--version'])
840840
PROG 2.0
841841

842-
Only actions that consume command-line arguments (e.g. ``'store'``,
843-
``'append'`` or ``'extend'``) can be used with positional arguments.
842+
Note that only actions that consume command-line arguments (e.g. ``'store'``,
843+
``'append'`` or ``'extend'``) can be used with positional arguments. You may
844+
also specify an arbitrary action by passing an :class:`Action` subclass or
845+
other object that implements the same interface.
844846

845847
.. class:: BooleanOptionalAction
846848

847-
You may also specify an arbitrary action by passing an :class:`Action` subclass or
848-
other object that implements the same interface. The :class:`!BooleanOptionalAction`
849-
is available in :mod:`!argparse` and adds support for boolean actions such as
850-
``--foo`` and ``--no-foo``::
849+
A subclass of :class:`Action` for handling boolean flags with positive
850+
and negative options. Adding a single argument such as ``--foo`` automatically
851+
creates both ``--foo`` and ``--no-foo`` options, storing ``True`` and ``False``
852+
respectively::
851853

852854
>>> import argparse
853855
>>> parser = argparse.ArgumentParser()

0 commit comments

Comments
 (0)
0