[Python-checkins] cpython (2.7): Note the store_true and store_false also create the appropriate defaults.
raymond.hettinger
python-checkins at python.org
Sun Nov 20 20:05:34 CET 2011
http://hg.python.org/cpython/rev/49677cc6d83a
changeset: 73628:49677cc6d83a
branch: 2.7
user: Raymond Hettinger <python at rcn.com>
date: Sun Nov 20 11:05:23 2011 -0800
summary:
Note the store_true and store_false also create the appropriate defaults.
files:
Doc/library/argparse.rst | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -670,15 +670,17 @@
>>> parser.parse_args('--foo'.split())
Namespace(foo=42)
-* ``'store_true'`` and ``'store_false'`` - These store the values ``True`` and
- ``False`` respectively. These are special cases of ``'store_const'``. For
- example::
+* ``'store_true'`` and ``'store_false'`` - These are special cases of
+ ``'store_const'`` using for storing the values ``True`` and ``False``
+ respectively. In addition, they create default values of *False* and *True*
+ respectively. For example::
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--foo', action='store_true')
>>> parser.add_argument('--bar', action='store_false')
+ >>> parser.add_argument('--baz', action='store_false')
>>> parser.parse_args('--foo --bar'.split())
- Namespace(bar=False, foo=True)
+ Namespace(bar=False, baz=True, foo=True)
* ``'append'`` - This stores a list, and appends each argument value to the
list. This is useful to allow an option to be specified multiple times.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list