|
7 | 7 | \hsection{Basic Functionality and Examples}% |
8 | 8 | \label{sec:lists:basicFunctions}% |
9 | 9 | % |
10 | | -\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{lists_1.py}{--args format}{lists:lists_1}{% |
| 10 | +\gitPythonAndOutput{\programmingWithPythonCodeRepo}{collections}{lists_1.py}{--args format}{lists:lists_1}{% |
11 | 11 | A first example for using lists in \python: creating, indexing, printing of and appending elements and other lists to lists.}% |
12 | 12 | % |
13 | | -\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{lists_2.py}{--args format}{lists:lists_2}{% |
| 13 | +\gitPythonAndOutput{\programmingWithPythonCodeRepo}{collections}{lists_2.py}{--args format}{lists:lists_2}{% |
14 | 14 | A second example of using lists in \python: inserting and deleting elements, sorting and reversing lists.}% |
15 | 15 | % |
16 | | -\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{lists_3.py}{--args format}{lists:lists_3}{% |
| 16 | +\gitPythonAndOutput{\programmingWithPythonCodeRepo}{collections}{lists_3.py}{--args format}{lists:lists_3}{% |
17 | 17 | A third example of using lists in \python: slicing, adding, and multiplying lists.}% |
18 | 18 | % |
19 | 19 | In \cref{lst:lists:lists_1}, we provide some first examples for using lists. |
|
143 | 143 | \hsection{An Example of Errors and a new Tool}% |
144 | 144 | \label{sec:listExampleForErrorsAndRuff}% |
145 | 145 | % |
146 | | -\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{lists_error.py}{--args format}{lists:lists_error}{% |
| 146 | +\gitPythonAndOutput{\programmingWithPythonCodeRepo}{collections}{lists_error.py}{--args format}{lists:lists_error}{% |
147 | 147 | A program processing lists which exhibits some subtle errors and inefficiencies.} |
148 | 148 |
|
149 | 149 | Now, in the previous chapter, we learned that static code analysis tools can help us to discover subtle problems in our programs. |
|
153 | 153 | It does not have any \emph{error} in the strict sense. |
154 | 154 | We can execute it just fine and it will produce the output \textil{[1, 2, 3]} as shown in \cref{exec:lists:lists_error}. |
155 | 155 |
|
156 | | -\gitOutputTool{\programmingWithPythonCodeRepo}{.}{scripts/mypy.sh 02_collections lists_error.py}{lists:lists_error:mypy}{% |
| 156 | +\gitOutputTool{\programmingWithPythonCodeRepo}{.}{_scripts_/mypy.sh collections lists_error.py}{lists:lists_error:mypy}{% |
157 | 157 | The results of static type checking with \mypy\ of the program given in \cref{lst:lists:lists_error}.} |
158 | 158 |
|
159 | 159 | However, upon closer inspection, we discover some issues. |
|
179 | 179 | We provide a script for using \ruff\ with a reasonable default configuration in \cref{lst:bash:ruff} on \cpageref{lst:bash:ruff}.% |
180 | 180 | }% |
181 | 181 | % |
182 | | -\gitOutputTool{\programmingWithPythonCodeRepo}{.}{scripts/ruff.sh 02_collections lists_error.py}{lists:lists_error:ruff}{% |
| 182 | +\gitOutputTool{\programmingWithPythonCodeRepo}{.}{_scripts_/ruff.sh collections lists_error.py}{lists:lists_error:ruff}{% |
183 | 183 | The results of linting with \ruff\ of the program given in \cref{lst:lists:lists_error}. (We used the script given in \cref{lst:bash:ruff} on \cpageref{lst:bash:ruff} to apply \ruff.)}% |
184 | 184 | % |
185 | 185 | Let us apply \ruff\ to the program \textil{lists_error.py} given in \cref{lst:lists:lists_error}, which produces the output \cref{exec:lists:lists_error:ruff}. |
|
199 | 199 | It basically creates a list via \pythonil{[1, 2, 3]} and then immediately makes a copy of it via the \pythonilIdx{list} function wrapped around the list specification. |
200 | 200 | We can leave this outer call to \pythonil{list} away. |
201 | 201 |
|
202 | | -\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{lists_fixed.py}{--args format}{lists:lists_fixed}{% |
| 202 | +\gitPythonAndOutput{\programmingWithPythonCodeRepo}{collections}{lists_fixed.py}{--args format}{lists:lists_fixed}{% |
203 | 203 | The corrected version of~\cref{lst:lists:lists_error}, taking into account the information given by \mypy\ in \cref{exec:lists:lists_error:mypy} and \ruff\ in \cref{exec:lists:lists_error:ruff}.}% |
204 | 204 | % |
205 | 205 | % |
|
220 | 220 | % |
221 | 221 | \FloatBarrier% |
222 | 222 | % |
223 | | -\gitOutputTool{\programmingWithPythonCodeRepo}{.}{scripts/mypy.sh 02_collections lists_fixed.py}{lists:lists_fixed:mypy}{% |
| 223 | +\gitOutputTool{\programmingWithPythonCodeRepo}{.}{_scripts_/mypy.sh collections lists_fixed.py}{lists:lists_fixed:mypy}{% |
224 | 224 | The results of static type checking with \mypy\ of the program given in \cref{lst:lists:lists_fixed}.}% |
225 | 225 | % |
226 | | -\gitOutputTool{\programmingWithPythonCodeRepo}{.}{scripts/ruff.sh 02_collections lists_fixed.py}{lists:lists_fixed:ruff}{% |
| 226 | +\gitOutputTool{\programmingWithPythonCodeRepo}{.}{_scripts_/ruff.sh collections lists_fixed.py}{lists:lists_fixed:ruff}{% |
227 | 227 | The results of static type checking with \ruff\ of the program given in \cref{lst:lists:lists_fixed}.} |
228 | 228 |
|
229 | 229 | Well, this was only a two-line program. |
|
0 commit comments