From: Raymond Hettinger Date: Sun, 20 Nov 2011 19:05:23 +0000 (-0800) Subject: Issue #25314: store_true and store_false also create appropriate defaults. X-Git-Tag: v3.6.0a1~308^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9cddccf8c165f461ace35302187ce32a3c38d7f;p=python Issue #25314: store_true and store_false also create appropriate defaults. --- diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 2877437b99..785ecbf44b 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -729,15 +729,17 @@ how the command-line arguments should be handled. The supplied 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'`` 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.