File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,8 @@ exception:
97
97
98
98
An example using only Unix style options:
99
99
100
+ .. doctest ::
101
+
100
102
>>> import getopt
101
103
>>> args = ' -a -b -cfoo -d bar a1 a2' .split()
102
104
>>> args
@@ -109,6 +111,8 @@ An example using only Unix style options:
109
111
110
112
Using long option names is equally easy:
111
113
114
+ .. doctest ::
115
+
112
116
>>> s = ' --condition=foo --testing --output-file abc.def -x a1 a2'
113
117
>>> args = s.split()
114
118
>>> args
@@ -120,7 +124,9 @@ Using long option names is equally easy:
120
124
>>> args
121
125
['a1', 'a2']
122
126
123
- In a script, typical usage is something like this::
127
+ In a script, typical usage is something like this:
128
+
129
+ .. testcode ::
124
130
125
131
import getopt, sys
126
132
@@ -150,7 +156,9 @@ In a script, typical usage is something like this::
150
156
main()
151
157
152
158
Note that an equivalent command line interface could be produced with less code
153
- and more informative help and error messages by using the :mod: `argparse ` module::
159
+ and more informative help and error messages by using the :mod: `argparse ` module:
160
+
161
+ .. testcode ::
154
162
155
163
import argparse
156
164
You can’t perform that action at this time.
0 commit comments