Issue #13605: add documentation for nargs=argparse.REMAINDER
This commit is contained in:
parent
f0229aa51c
commit
16bd0b4463
@ -840,6 +840,17 @@ values are:
|
|||||||
usage: PROG [-h] foo [foo ...]
|
usage: PROG [-h] foo [foo ...]
|
||||||
PROG: error: too few arguments
|
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
|
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
|
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.
|
will be consumed and a single item (not a list) will be produced.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user