# HG changeset patch # Parent 7d8339083cb3ae4352d7517325b58f7fb750a5d9 diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -18,6 +18,41 @@ will figure out how to parse those out o module also automatically generates help and usage messages and issues errors when users give the program invalid arguments. +Quick Reference +--------------- + ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ +| |``nargs``|``const`` |``default``|``type``|``choices``|``required``|``help``|``metavar``|``dest``|``version``| ++=================+=========+================+===========+========+===========+============+========+===========+========+===========+ +|``store`` |x |if ``nargs='?'``|x |x |x |x |x |x |x | | ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ +|``store_const`` | |x |x | | |x |x |x |x | | ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ +|``store_true`` | |x |x | | |x |x |x |x | | ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ +|``store_false`` | |x |x | | |x |x |x |x | | ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ +|``append`` |x |if ``nargs='?'``|x |x |x |x |x |x |x | | ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ +|``append_const`` | |x |x | | |x |x |x |x | | ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ +|``count`` | | | | | | |x |x |x | | ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ +|``version`` | | | | | | | | | |x | ++-----------------+---------+----------------+-----------+--------+-----------+------------+--------+-----------+--------+-----------+ + +.. note:: + + * ``default`` can be set to ``argparse.SUPPRESS`` to prevent the + attribute from being added + + * ``nargs='?'`` will use ``default`` if the argument is not + specified, but ``const`` if the argument is specified with no + value provided + + * list-type ``nargs`` (an ``int``, ``'*'`` or ``'+'``) causes a + list to be used: ``store`` becomes a list and ``append`` becomes + a list of lists Example -------