Skip to content

Commit 5aae0a0

Browse files
Updates
1 parent 9845e44 commit 5aae0a0

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

Doc/library/argparse.rst

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ the extracted data in a :class:`argparse.Namespace` object::
4949
args = parser.parse_args()
5050
print(args.filename, args.count, args.verbose)
5151

52+
.. note::
53+
If you're looking a guide about how to upgrade optparse code
54+
to argparse, see :ref:`Upgrading Optparse Code <upgrading-optparse-code>`.
5255

5356
ArgumentParser objects
5457
----------------------
@@ -124,7 +127,9 @@ how to display the name of the program in help messages. This default is almost
124127
always desirable because it will make the help messages match the name that was
125128
used to invoke the program on the command line. However, to change this default
126129
behavior, another value can be supplied using the ``prog=`` argument to
127-
:class:`ArgumentParser`::
130+
:class:`ArgumentParser`
131+
132+
::
128133

129134
>>> parser = argparse.ArgumentParser(prog='myprogram')
130135
>>> parser.print_help()
@@ -1523,7 +1528,7 @@ Sub-commands
15231528
Description of parameters:
15241529

15251530
* title - title for the sub-parser group in help output; by default
1526-
"subcommands" if description is provided, otherwise uses title for
1531+
"sub-commands" if description is provided, otherwise uses title for
15271532
positional arguments
15281533

15291534
* description - description for the sub-parser group in help output, by
@@ -1542,7 +1547,7 @@ Sub-commands
15421547
* dest_ - name of the attribute under which sub-command name will be
15431548
stored; by default ``None`` and no value is stored
15441549

1545-
* required_ - Whether or not a subcommand must be provided, by default
1550+
* required_ - Whether or not a sub-command must be provided, by default
15461551
``False`` (added in 3.7)
15471552

15481553
* help_ - help for sub-parser group in help output, by default ``None``
@@ -1619,8 +1624,8 @@ Sub-commands
16191624
appear in their own group in the help output. For example::
16201625

16211626
>>> parser = argparse.ArgumentParser()
1622-
>>> subparsers = parser.add_subparsers(title='subcommands',
1623-
... description='valid subcommands',
1627+
>>> subparsers = parser.add_subparsers(title='sub-commands',
1628+
... description='valid sub-commands',
16241629
... help='additional help')
16251630
>>> subparsers.add_parser('foo')
16261631
>>> subparsers.add_parser('bar')
@@ -1630,8 +1635,8 @@ Sub-commands
16301635
options:
16311636
-h, --help show this help message and exit
16321637

1633-
subcommands:
1634-
valid subcommands
1638+
sub-commands:
1639+
valid sub-commands
16351640

16361641
{foo,bar} additional help
16371642

@@ -2051,8 +2056,6 @@ remaining unparsed argument strings.
20512056

20522057
.. versionadded:: 3.7
20532058

2054-
.. _upgrading-optparse-code:
2055-
20562059

20572060
Exceptions
20582061
----------
@@ -2067,3 +2070,15 @@ Exceptions
20672070
.. exception:: ArgumentTypeError
20682071

20692072
Raised when something goes wrong converting a command line string to a type.
2073+
2074+
.. We use the "rubric" directive here to avoid creating
2075+
the "Reference" subsection in the TOC.
2076+
2077+
.. rubric:: Reference
2078+
2079+
.. toctree::
2080+
:maxdepth: 1
2081+
:caption: Guides and Tutorials
2082+
2083+
../howto/argparse.rst
2084+
argparse-optparse.rst

0 commit comments

Comments
 (0)