diff options
author | Sandro Tosi <sandro.tosi@gmail.com> | 2012-01-19 20:59:55 (GMT) |
---|---|---|
committer | Sandro Tosi <sandro.tosi@gmail.com> | 2012-01-19 20:59:55 (GMT) |
commit | 16bd0b44636b1fe21def21b6e2537b58315d3fc6 (patch) | |
tree | 24dfc123f44cc4da26ef512ffa8d29f6198a484e /Doc/library/argparse.rst | |
parent | f0229aa51cd089076a1ea4a9a09689831cea012f (diff) | |
download | cpython-16bd0b44636b1fe21def21b6e2537b58315d3fc6.zip cpython-16bd0b44636b1fe21def21b6e2537b58315d3fc6.tar.gz cpython-16bd0b44636b1fe21def21b6e2537b58315d3fc6.tar.bz2 |
Issue #13605: add documentation for nargs=argparse.REMAINDER
Diffstat (limited to 'Doc/library/argparse.rst')
-rw-r--r-- | Doc/library/argparse.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 28537e9..a1ddfc9 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -840,6 +840,17 @@ values are: usage: PROG [-h] foo [foo ...] PROG: error: too few arguments +* ``argparse.REMAINDER``. All the remaining command-line arguments + are gathered into a lits. This is commonly useful for command line + utilities that dispatch to other command line utilities. + + >>> parser = argparse.ArgumentParser(prog='PROG') + >>> parser.add_argument('--foo') + >>> parser.add_argument('command') + >>> parser.add_argument('args', nargs=argparse.REMAINDER) + >>> print parser.parse_args('--foo B XX YY ZZ'.split()) + Namespace(args=['YY', 'ZZ'], command='XX', foo='B') + If the ``nargs`` keyword argument is not provided, the number of arguments consumed is determined by the action_. Generally this means a single command-line argument will be consumed and a single item (not a list) will be produced. |