[Python-checkins] cpython (2.7): Issue #10772: add count and help argparse action; patch by Marc Sibson
sandro.tosi
python-checkins at python.org
Wed Jan 4 23:26:40 CET 2012
http://hg.python.org/cpython/rev/278fbd7b9608
changeset: 74272:278fbd7b9608
branch: 2.7
parent: 74256:789d59773801
user: Sandro Tosi <sandro.tosi at gmail.com>
date: Wed Jan 04 23:24:48 2012 +0100
summary:
Issue #10772: add count and help argparse action; patch by Marc Sibson
files:
Doc/library/argparse.rst | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -703,6 +703,19 @@
>>> parser.parse_args('--str --int'.split())
Namespace(types=[<type 'str'>, <type 'int'>])
+* ``'count'`` - This counts the number of times a keyword argument occurs. For
+ example, this is useful for increasing verbosity levels::
+
+ >>> parser = argparse.ArgumentParser()
+ >>> parser.add_argument('--verbose', '-v', action='count')
+ >>> parser.parse_args('-vvv'.split())
+ Namespace(verbose=3)
+
+* ``'help'`` - This prints a complete help message for all the options in the
+ current parser and then exits. By default a help action is automatically
+ added to the parser. See :class:`ArgumentParser` for details of how the
+ output is created.
+
* ``'version'`` - This expects a ``version=`` keyword argument in the
:meth:`~ArgumentParser.add_argument` call, and prints version information
and exits when invoked.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list