summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-11-20 19:05:23 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-11-20 19:05:23 (GMT)
commit421467f8f0c9fe6198f882e1925c47566ca3023b (patch)
tree4292f551486330a0fb834eecf482bf1ea15c55ad
parent7d1483cbadbe48620964348a2039690624e7dc8e (diff)
downloadcpython-421467f8f0c9fe6198f882e1925c47566ca3023b.zip
cpython-421467f8f0c9fe6198f882e1925c47566ca3023b.tar.gz
cpython-421467f8f0c9fe6198f882e1925c47566ca3023b.tar.bz2
Note the store_true and store_false also create the appropriate defaults.
-rw-r--r--Doc/library/argparse.rst10
1 files changed, 6 insertions, 4 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 3b83110..38e3f3e 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -670,15 +670,17 @@ how the command-line arguments should be handled. The supported actions are:
>>> 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.