@@ -720,7 +720,7 @@ how the command-line arguments should be handled. The supported actions are:
720720
721721* ``'version' `` - This expects a ``version= `` keyword argument in the
722722 :meth: `~ArgumentParser.add_argument ` call, and prints version information
723- and exits when invoked.
723+ and exits when invoked::
724724
725725 >>> import argparse
726726 >>> parser = argparse.ArgumentParser(prog='PROG')
@@ -772,8 +772,8 @@ single action to be taken. The ``nargs`` keyword argument associates a
772772different number of command-line arguments with a single action. The supported
773773values are:
774774
775- * ``N `` (an integer). ``N `` arguments from the command line will be gathered together into a
776- list. For example::
775+ * ``N `` (an integer). ``N `` arguments from the command line will be gathered
776+ together into a list. For example::
777777
778778 >>> parser = argparse.ArgumentParser()
779779 >>> parser.add_argument('--foo', nargs=2)
@@ -842,7 +842,7 @@ values are:
842842
843843* ``argparse.REMAINDER ``. All the remaining command-line arguments are gathered
844844 into a list. This is commonly useful for command line utilities that dispatch
845- to other command line utilities.
845+ to other command line utilities::
846846
847847 >>> parser = argparse.ArgumentParser(prog='PROG')
848848 >>> parser.add_argument('--foo')
@@ -865,7 +865,8 @@ the various :class:`ArgumentParser` actions. The two most common uses of it are
865865
866866* When :meth: `~ArgumentParser.add_argument ` is called with
867867 ``action='store_const' `` or ``action='append_const' ``. These actions add the
868- ``const `` value to one of the attributes of the object returned by :meth: `~ArgumentParser.parse_args `. See the action _ description for examples.
868+ ``const `` value to one of the attributes of the object returned by
869+ :meth: `~ArgumentParser.parse_args `. See the action _ description for examples.
869870
870871* When :meth: `~ArgumentParser.add_argument ` is called with option strings
871872 (like ``-f `` or ``--foo ``) and ``nargs='?' ``. This creates an optional
@@ -1576,21 +1577,21 @@ FileType objects
15761577 The :class: `FileType ` factory creates objects that can be passed to the type
15771578 argument of :meth: `ArgumentParser.add_argument `. Arguments that have
15781579 :class: `FileType ` objects as their type will open command-line arguments as files
1579- with the requested modes and buffer sizes:
1580+ with the requested modes and buffer sizes::
15801581
1581- >>> parser = argparse.ArgumentParser()
1582- >>> parser.add_argument(' --output' , type = argparse.FileType(' wb' , 0 ))
1583- >>> parser.parse_args([' --output' , ' out' ])
1584- Namespace(output=<_io.BufferedWriter name='out'>)
1582+ >>> parser = argparse.ArgumentParser()
1583+ >>> parser.add_argument('--output', type=argparse.FileType('wb', 0))
1584+ >>> parser.parse_args(['--output', 'out'])
1585+ Namespace(output=<_io.BufferedWriter name='out'>)
15851586
15861587 FileType objects understand the pseudo-argument ``'-' `` and automatically
15871588 convert this into ``sys.stdin `` for readable :class: `FileType ` objects and
1588- ``sys.stdout `` for writable :class: `FileType ` objects:
1589+ ``sys.stdout `` for writable :class: `FileType ` objects::
15891590
1590- >>> parser = argparse.ArgumentParser()
1591- >>> parser.add_argument(' infile' , type = argparse.FileType(' r' ))
1592- >>> parser.parse_args([' -' ])
1593- Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>)
1591+ >>> parser = argparse.ArgumentParser()
1592+ >>> parser.add_argument('infile', type=argparse.FileType('r'))
1593+ >>> parser.parse_args(['-'])
1594+ Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>)
15941595
15951596
15961597Argument groups
0 commit comments