diff options
Diffstat (limited to 'Doc/library/argparse.rst')
-rw-r--r-- | Doc/library/argparse.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 1973afc..cef197f 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -844,6 +844,8 @@ values are: Note that ``nargs=1`` produces a list of one item. This is different from the default, in which the item is produced by itself. +.. index:: single: ? (question mark); in argparse module + * ``'?'``. One argument will be consumed from the command line if possible, and produced as a single item. If no command-line argument is present, the value from default_ will be produced. Note that for optional arguments, there is an @@ -876,6 +878,8 @@ values are: Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>, outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>) +.. index:: single: * (asterisk); in argparse module + * ``'*'``. All command-line arguments present are gathered into a list. Note that it generally doesn't make much sense to have more than one positional argument with ``nargs='*'``, but multiple optional arguments with ``nargs='*'`` is @@ -888,6 +892,8 @@ values are: >>> parser.parse_args('a b --foo x y --bar 1 2'.split()) Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y']) +.. index:: single: + (plus); in argparse module + * ``'+'``. Just like ``'*'``, all command-line args present are gathered into a list. Additionally, an error message will be generated if there wasn't at least one command-line argument present. For example:: |