diff options
author | Sandro Tosi <sandro.tosi@gmail.com> | 2012-01-19 22:00:21 +0100 |
---|---|---|
committer | Sandro Tosi <sandro.tosi@gmail.com> | 2012-01-19 22:00:21 +0100 |
commit | 83d32c9135b75b366ebe0542b4c677c32682b0e1 (patch) | |
tree | d5a5fdb27075b30993dc70b77f93e64a0cba1afd | |
parent | 188bee58737d366ea4bf296972d3389f64d1dae7 (diff) | |
parent | 16bd0b44636b1fe21def21b6e2537b58315d3fc6 (diff) | |
download | cpython-git-83d32c9135b75b366ebe0542b4c677c32682b0e1.tar.gz |
Issue #13605: merge with 3.2
-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 1f0ea2d611..8ddccfb572 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -859,6 +859,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. |