Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da98ed0

Browse filesBrowse files
authored
gh-106535: Soft deprecate the getopt module (#105735)
The getopt module exists since the initial revision of the Python source code (1990). The optparse module was added to Python 2.3. When Python 2.7 added the 3rd argparse module, the optparse module was soft deprecated. Soft deprecate the getopt module.
1 parent b305c69 commit da98ed0
Copy full SHA for da98ed0

File tree

1 file changed

+13
-8
lines changed
Filter options

1 file changed

+13
-8
lines changed

‎Doc/library/getopt.rst

Copy file name to clipboardExpand all lines: Doc/library/getopt.rst
+13-8Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,23 @@
77

88
**Source code:** :source:`Lib/getopt.py`
99

10+
.. deprecated:: 3.13
11+
The :mod:`getopt` module is :term:`soft deprecated` and will not be
12+
developed further; development will continue with the :mod:`argparse`
13+
module.
14+
1015
.. note::
1116

1217
The :mod:`getopt` module is a parser for command line options whose API is
13-
designed to be familiar to users of the C :c:func:`getopt` function. Users who
14-
are unfamiliar with the C :c:func:`getopt` function or who would like to write
18+
designed to be familiar to users of the C :c:func:`!getopt` function. Users who
19+
are unfamiliar with the C :c:func:`!getopt` function or who would like to write
1520
less code and get better help and error messages should consider using the
1621
:mod:`argparse` module instead.
1722

1823
--------------
1924

2025
This module helps scripts to parse the command line arguments in ``sys.argv``.
21-
It supports the same conventions as the Unix :c:func:`getopt` function (including
26+
It supports the same conventions as the Unix :c:func:`!getopt` function (including
2227
the special meanings of arguments of the form '``-``' and '``--``'). Long
2328
options similar to those supported by GNU software may be used as well via an
2429
optional third argument.
@@ -33,11 +38,11 @@ exception:
3338
be parsed, without the leading reference to the running program. Typically, this
3439
means ``sys.argv[1:]``. *shortopts* is the string of option letters that the
3540
script wants to recognize, with options that require an argument followed by a
36-
colon (``':'``; i.e., the same format that Unix :c:func:`getopt` uses).
41+
colon (``':'``; i.e., the same format that Unix :c:func:`!getopt` uses).
3742

3843
.. note::
3944

40-
Unlike GNU :c:func:`getopt`, after a non-option argument, all further
45+
Unlike GNU :c:func:`!getopt`, after a non-option argument, all further
4146
arguments are considered also non-options. This is similar to the way
4247
non-GNU Unix systems work.
4348

@@ -71,7 +76,7 @@ exception:
7176
non-option argument is encountered.
7277

7378
If the first character of the option string is ``'+'``, or if the environment
74-
variable :envvar:`POSIXLY_CORRECT` is set, then option processing stops as
79+
variable :envvar:`!POSIXLY_CORRECT` is set, then option processing stops as
7580
soon as a non-option argument is encountered.
7681

7782

@@ -81,9 +86,9 @@ exception:
8186
an option requiring an argument is given none. The argument to the exception is
8287
a string indicating the cause of the error. For long options, an argument given
8388
to an option which does not require one will also cause this exception to be
84-
raised. The attributes :attr:`msg` and :attr:`opt` give the error message and
89+
raised. The attributes :attr:`!msg` and :attr:`!opt` give the error message and
8590
related option; if there is no specific option to which the exception relates,
86-
:attr:`opt` is an empty string.
91+
:attr:`!opt` is an empty string.
8792

8893
.. XXX deprecated?
8994
.. exception:: error

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.