(original) (raw)
changeset: 74529:1b481e76cd16 branch: 2.7 parent: 74526:35665f6f3674 user: Sandro Tosi sandro.tosi@gmail.com date: Thu Jan 19 22:22:35 2012 +0100 files: Doc/library/argparse.rst description: Issue #13605: more meaningful example + fixes diff -r 35665f6f3674 -r 1b481e76cd16 Doc/library/argparse.rst --- a/Doc/library/argparse.rst Thu Jan 19 21:59:34 2012 +0100 +++ b/Doc/library/argparse.rst Thu Jan 19 22:22:35 2012 +0100 @@ -838,16 +838,16 @@ 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. +* ``argparse.REMAINDER``. All the remaining command-line arguments are gathered + into a list. 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') + >>> print parser.parse_args('--foo B cmd --arg1 XX ZZ'.split()) + Namespace(args=['--arg1', 'XX', 'ZZ'], command='cmd', 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 /sandro.tosi@gmail.com