mirror of
https://github.com/python/cpython.git
synced 2025-10-02 05:12:23 +00:00
[3.14] GH-106235: Clarify parse_known_args
documentation by removing "remaining" (GH-126921) (#134913)
GH-106235: Clarify `parse_known_args` documentation by removing "remaining" (GH-126921)
(cherry picked from commit a4251411a9
)
Co-authored-by: Savannah Bailey <savannahostrowski@gmail.com>
This commit is contained in:
parent
32574d4bc0
commit
2912fcc2e4
1 changed files with 9 additions and 6 deletions
|
@ -2122,12 +2122,15 @@ Partial parsing
|
||||||
|
|
||||||
.. method:: ArgumentParser.parse_known_args(args=None, namespace=None)
|
.. method:: ArgumentParser.parse_known_args(args=None, namespace=None)
|
||||||
|
|
||||||
Sometimes a script may only parse a few of the command-line arguments, passing
|
Sometimes a script only needs to handle a specific set of command-line
|
||||||
the remaining arguments on to another script or program. In these cases, the
|
arguments, leaving any unrecognized arguments for another script or program.
|
||||||
:meth:`~ArgumentParser.parse_known_args` method can be useful. It works much like
|
In these cases, the :meth:`~ArgumentParser.parse_known_args` method can be
|
||||||
:meth:`~ArgumentParser.parse_args` except that it does not produce an error when
|
useful.
|
||||||
extra arguments are present. Instead, it returns a two item tuple containing
|
|
||||||
the populated namespace and the list of remaining argument strings.
|
This method works similarly to :meth:`~ArgumentParser.parse_args`, but it does
|
||||||
|
not raise an error for extra, unrecognized arguments. Instead, it parses the
|
||||||
|
known arguments and returns a two item tuple that contains the populated
|
||||||
|
namespace and the list of any unrecognized arguments.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue