Skip to content

Commit 1866873

Browse files
committed
Update argparse.rst
Reduces to a single example (with default arg) and clarifies phrasing.
1 parent 6e0a2fa commit 1866873

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Doc/library/argparse.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,12 @@ how the command-line arguments should be handled. The supplied actions are:
774774
>>> parser.parse_args('--foo --bar'.split())
775775
Namespace(foo=True, bar=False, baz=True)
776776

777-
* ``'append'`` - This stores a list, and appends each argument value to the
778-
list. It is useful to allow an option to be specified multiple times.
779-
If the default value is non-empty, the default elements will be present
780-
in the parsed value for the option, with any values from the
781-
command line appended after those default values. Example usage::
777+
* ``'append'`` - This appends each argument value to a list.
778+
It is useful for allowing an option to be specified multiple times.
779+
If the default value is a non-empty list, the parsed value will start
780+
with the default list's elements and any values from the command line
781+
will be appended after those default values. Example usage::
782782

783-
>>> parser = argparse.ArgumentParser()
784-
>>> parser.add_argument('--foo', action='append')
785-
>>> parser.parse_args('--foo 1 --foo 2'.split())
786-
Namespace(foo=['1', '2'])
787783
>>> parser = argparse.ArgumentParser()
788784
>>> parser.add_argument('--foo', action='append', default=['0'])
789785
>>> parser.parse_args('--foo 1 --foo 2'.split())

0 commit comments

Comments
 (0)