[Python-checkins] cpython (merge 3.5 -> default): Issue #25314: Merge argparse doc from 3.5

martin.panter python-checkins at python.org
Mon Mar 28 02:17:12 EDT 2016


https://hg.python.org/cpython/rev/9fdeca5fdbf0
changeset:   100780:9fdeca5fdbf0
parent:      100777:72c457f9533a
parent:      100779:566fe3564684
user:        Martin Panter <vadmium+py at gmail.com>
date:        Mon Mar 28 06:13:52 2016 +0000
summary:
  Issue #25314: Merge argparse doc from 3.5

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
@@ -729,15 +729,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'`` used 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(foo=True, bar=False, baz=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: https://hg.python.org/cpython


More information about the Python-checkins mailing list