@@ -898,6 +898,8 @@ values are:
898898 usage: PROG [-h] foo [foo ...]
899899 PROG: error: too few arguments
900900
901+ .. _`argparse.REMAINDER` :
902+
901903* ``argparse.REMAINDER ``. All the remaining command-line arguments are gathered
902904 into a list. This is commonly useful for command line utilities that dispatch
903905 to other command line utilities::
@@ -1324,8 +1326,11 @@ The parse_args() method
13241326 created and how they are assigned. See the documentation for
13251327 :meth: `add_argument ` for details.
13261328
1327- By default, the argument strings are taken from :data: `sys.argv `, and a new empty
1328- :class: `Namespace ` object is created for the attributes.
1329+ * args _ - List of strings to parse. The default is taken from
1330+ :data: `sys.argv `.
1331+
1332+ * namespace _ - An object to take the attributes. The default is a new empty
1333+ :class: `Namespace ` object.
13291334
13301335
13311336Option value syntax
@@ -1467,6 +1472,7 @@ unambiguous (the prefix matches a unique option)::
14671472An error is produced for arguments that could produce more than one options.
14681473This feature can be disabled by setting :ref: `allow_abbrev ` to ``False ``.
14691474
1475+ .. _args :
14701476
14711477Beyond ``sys.argv ``
14721478^^^^^^^^^^^^^^^^^^^
@@ -1488,6 +1494,7 @@ interactive prompt::
14881494 >>> parser.parse_args(['1', '2', '3', '4', '--sum'])
14891495 Namespace(accumulate=<built-in function sum>, integers=[1, 2, 3, 4])
14901496
1497+ .. _namespace :
14911498
14921499The Namespace object
14931500^^^^^^^^^^^^^^^^^^^^
@@ -2008,7 +2015,12 @@ A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
20082015* Replace ``(options, args) = parser.parse_args() `` with ``args =
20092016 parser.parse_args() `` and add additional :meth: `ArgumentParser.add_argument `
20102017 calls for the positional arguments. Keep in mind that what was previously
2011- called ``options ``, now in :mod: `argparse ` context is called ``args ``.
2018+ called ``options ``, now in the :mod: `argparse ` context is called ``args ``.
2019+
2020+ * Replace :meth: `optparse.OptionParser.disable_interspersed_args `
2021+ by setting ``nargs `` of a positional argument to `argparse.REMAINDER `_, or
2022+ use :meth: `~ArgumentParser.parse_known_args ` to collect unparsed argument
2023+ strings in a separate list.
20122024
20132025* Replace callback actions and the ``callback_* `` keyword arguments with
20142026 ``type `` or ``action `` arguments.
0 commit comments