@@ -844,6 +844,8 @@ values are:
844
844
Note that ``nargs=1 `` produces a list of one item. This is different from
845
845
the default, in which the item is produced by itself.
846
846
847
+ .. index :: single: ? (question mark); in argparse module
848
+
847
849
* ``'?' ``. One argument will be consumed from the command line if possible, and
848
850
produced as a single item. If no command-line argument is present, the value from
849
851
default _ will be produced. Note that for optional arguments, there is an
@@ -876,6 +878,8 @@ values are:
876
878
Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>,
877
879
outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>)
878
880
881
+ .. index :: single: * (asterisk); in argparse module
882
+
879
883
* ``'*' ``. All command-line arguments present are gathered into a list. Note that
880
884
it generally doesn't make much sense to have more than one positional argument
881
885
with ``nargs='*' ``, but multiple optional arguments with ``nargs='*' `` is
@@ -888,6 +892,8 @@ values are:
888
892
>>> parser.parse_args('a b --foo x y --bar 1 2'.split())
889
893
Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])
890
894
895
+ .. index :: single: + (plus); in argparse module
896
+
891
897
* ``'+' ``. Just like ``'*' ``, all command-line args present are gathered into a
892
898
list. Additionally, an error message will be generated if there wasn't at
893
899
least one command-line argument present. For example::
0 commit comments