mirror of https://github.com/python/cpython
Issue #25314: Merge argparse doc from 3.5
This commit is contained in:
commit
eba25880f8
|
@ -729,15 +729,17 @@ how the command-line arguments should be handled. The supplied actions are:
|
||||||
>>> parser.parse_args('--foo'.split())
|
>>> parser.parse_args('--foo'.split())
|
||||||
Namespace(foo=42)
|
Namespace(foo=42)
|
||||||
|
|
||||||
* ``'store_true'`` and ``'store_false'`` - These store the values ``True`` and
|
* ``'store_true'`` and ``'store_false'`` - These are special cases of
|
||||||
``False`` respectively. These are special cases of ``'store_const'``. For
|
``'store_const'`` used for storing the values ``True`` and ``False``
|
||||||
example::
|
respectively. In addition, they create default values of ``False`` and
|
||||||
|
``True`` respectively. For example::
|
||||||
|
|
||||||
>>> parser = argparse.ArgumentParser()
|
>>> parser = argparse.ArgumentParser()
|
||||||
>>> parser.add_argument('--foo', action='store_true')
|
>>> parser.add_argument('--foo', action='store_true')
|
||||||
>>> parser.add_argument('--bar', action='store_false')
|
>>> parser.add_argument('--bar', action='store_false')
|
||||||
|
>>> parser.add_argument('--baz', action='store_false')
|
||||||
>>> parser.parse_args('--foo --bar'.split())
|
>>> 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
|
* ``'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.
|
list. This is useful to allow an option to be specified multiple times.
|
||||||
|
|
Loading…
Reference in New Issue