[3.9] Fix error in argparse documentation example (GH-17399) (GH-21992)

Automerge-Triggered-By: @rhettinger
(cherry picked from commit 8784d3300e)


Co-authored-by: SarahPythonista <4283226+SarahPythonista@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2020-09-04 15:26:22 -07:00 committed by GitHub
parent 672d8b9190
commit 78ef1b6b12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1162,8 +1162,8 @@ keyword argument to :meth:`~ArgumentParser.add_argument`::
>>> parser.parse_args(['--foo', 'BAR'])
Namespace(foo='BAR')
>>> parser.parse_args([])
usage: argparse.py [-h] [--foo FOO]
argparse.py: error: option --foo is required
usage: [-h] --foo FOO
: error: the following arguments are required: --foo
As the example shows, if an option is marked as ``required``,
:meth:`~ArgumentParser.parse_args` will report an error if that option is not