Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98492a5

Browse files
committed
Issue #10772: add count and help argparse action; patch by Marc Sibson
1 parent 6497aa3 commit 98492a5

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Doc/library/argparse.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,19 @@ how the command-line arguments should be handled. The supported actions are:
705705
>>> parser.parse_args('--str --int'.split())
706706
Namespace(types=[<class 'str'>, <class 'int'>])
707707

708+
* ``'count'`` - This counts the number of times a keyword argument occurs. For
709+
example, this is useful for increasing verbosity levels::
710+
711+
>>> parser = argparse.ArgumentParser()
712+
>>> parser.add_argument('--verbose', '-v', action='count')
713+
>>> parser.parse_args('-vvv'.split())
714+
Namespace(verbose=3)
715+
716+
* ``'help'`` - This prints a complete help message for all the options in the
717+
current parser and then exits. By default a help action is automatically
718+
added to the parser. See :class:`ArgumentParser` for details of how the
719+
output is created.
720+
708721
* ``'version'`` - This expects a ``version=`` keyword argument in the
709722
:meth:`~ArgumentParser.add_argument` call, and prints version information
710723
and exits when invoked.

0 commit comments

Comments
 (0)