(original) (raw)

changeset: 74528:6b4cec0719a3 parent: 74525:053fbceaf789 parent: 74527:6f3d55f5a31e user: Sandro Tosi sandro.tosi@gmail.com date: Thu Jan 19 22:00:21 2012 +0100 files: Doc/library/argparse.rst description: Issue #13605: merge with 3.2 diff -r 053fbceaf789 -r 6b4cec0719a3 Doc/library/argparse.rst --- a/Doc/library/argparse.rst Thu Jan 19 08:48:18 2012 -0500 +++ b/Doc/library/argparse.rst Thu Jan 19 22:00:21 2012 +0100 @@ -859,6 +859,17 @@ 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. /sandro.tosi@gmail.com