@@ -900,6 +900,8 @@ values are:
900900 usage: PROG [-h] foo [foo ...]
901901 PROG: error: too few arguments
902902
903+ .. _`argparse.REMAINDER` :
904+
903905* ``argparse.REMAINDER ``. All the remaining command-line arguments are gathered
904906 into a list. This is commonly useful for command line utilities that dispatch
905907 to other command line utilities::
@@ -1326,8 +1328,11 @@ The parse_args() method
13261328 created and how they are assigned. See the documentation for
13271329 :meth: `add_argument ` for details.
13281330
1329- By default, the argument strings are taken from :data: `sys.argv `, and a new empty
1330- :class: `Namespace ` object is created for the attributes.
1331+ * args _ - List of strings to parse. The default is taken from
1332+ :data: `sys.argv `.
1333+
1334+ * namespace _ - An object to take the attributes. The default is a new empty
1335+ :class: `Namespace ` object.
13311336
13321337
13331338Option value syntax
@@ -1469,6 +1474,7 @@ unambiguous (the prefix matches a unique option)::
14691474An error is produced for arguments that could produce more than one options.
14701475This feature can be disabled by setting :ref: `allow_abbrev ` to ``False ``.
14711476
1477+ .. _args :
14721478
14731479Beyond ``sys.argv ``
14741480^^^^^^^^^^^^^^^^^^^
@@ -1490,6 +1496,7 @@ interactive prompt::
14901496 >>> parser.parse_args(['1', '2', '3', '4', '--sum'])
14911497 Namespace(accumulate=<built-in function sum>, integers=[1, 2, 3, 4])
14921498
1499+ .. _namespace :
14931500
14941501The Namespace object
14951502^^^^^^^^^^^^^^^^^^^^
@@ -2010,7 +2017,12 @@ A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
20102017* Replace ``(options, args) = parser.parse_args() `` with ``args =
20112018 parser.parse_args() `` and add additional :meth: `ArgumentParser.add_argument `
20122019 calls for the positional arguments. Keep in mind that what was previously
2013- called ``options ``, now in :mod: `argparse ` context is called ``args ``.
2020+ called ``options ``, now in the :mod: `argparse ` context is called ``args ``.
2021+
2022+ * Replace :meth: `optparse.OptionParser.disable_interspersed_args `
2023+ by setting ``nargs `` of a positional argument to `argparse.REMAINDER `_, or
2024+ use :meth: `~ArgumentParser.parse_known_args ` to collect unparsed argument
2025+ strings in a separate list.
20142026
20152027* Replace callback actions and the ``callback_* `` keyword arguments with
20162028 ``type `` or ``action `` arguments.
0 commit comments