7
7
8
8
**Source code: ** :source: `Lib/getopt.py `
9
9
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
+
10
15
.. note ::
11
16
12
17
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
15
20
less code and get better help and error messages should consider using the
16
21
:mod: `argparse ` module instead.
17
22
18
23
--------------
19
24
20
25
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
22
27
the special meanings of arguments of the form '``- ``' and '``-- ``'). Long
23
28
options similar to those supported by GNU software may be used as well via an
24
29
optional third argument.
@@ -33,11 +38,11 @@ exception:
33
38
be parsed, without the leading reference to the running program. Typically, this
34
39
means ``sys.argv[1:] ``. *shortopts * is the string of option letters that the
35
40
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).
37
42
38
43
.. note ::
39
44
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
41
46
arguments are considered also non-options. This is similar to the way
42
47
non-GNU Unix systems work.
43
48
@@ -71,7 +76,7 @@ exception:
71
76
non-option argument is encountered.
72
77
73
78
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
75
80
soon as a non-option argument is encountered.
76
81
77
82
@@ -81,9 +86,9 @@ exception:
81
86
an option requiring an argument is given none. The argument to the exception is
82
87
a string indicating the cause of the error. For long options, an argument given
83
88
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
85
90
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.
87
92
88
93
.. XXX deprecated?
89
94
.. exception :: error
0 commit comments