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
2025This 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
2227the special meanings of arguments of the form '``- ``' and '``-- ``'). Long
2328options similar to those supported by GNU software may be used as well via an
2429optional 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