Skip to content

Commit 6249135

Browse files
committed
several improvements and more examples of exception handling
1 parent 8c9d4a9 commit 6249135

File tree

15 files changed

+138
-38
lines changed

15 files changed

+138
-38
lines changed

scripts/pdflatex.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ echo "$(date +'%0Y-%0m-%0d %0R:%0S'): We will now perform runs of the tool chain
121121
watchFileContents=""
122122
oldWatchFileContents="old"
123123
cycle=0
124+
additional=1
124125

125-
while [ "$watchFileContents" != "$oldWatchFileContents" ] ; do
126+
while (("$additional" >= 0)) ; do
126127
cycle=$((cycle+1))
127128
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Now beginning build cycle $cycle."
128129

@@ -238,9 +239,17 @@ while [ "$watchFileContents" != "$oldWatchFileContents" ] ; do
238239
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Something odd is happening: We have performed $cycle cycles. That's too many. Let's quit."
239240
break
240241
fi
242+
243+
if [ "$watchFileContents" != "$oldWatchFileContents" ] ; then
244+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Auxiliary file contents changed. We need more cycles."
245+
additional=1
246+
else
247+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): Auxiliary file contents did not change. We do $additional more cycle(s)."
248+
additional=$(($additional-1))
249+
fi
241250
done
242251

243-
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): The tool chain has been applied until nothing changed anymore. We now check for errors."
252+
echo "$(date +'%0Y-%0m-%0d %0R:%0S'): The tool chain has been applied until nothing changed anymore (after $cycle cycles). We now check for errors."
244253

245254
latexWarningsCount=0
246255
latexWarningString=""

text/back/scripts.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
\Cref{lst:bash:pylint} offers exactly the same functionality for \pylint.
6262
It checks if this tool is installed and installs it if not.
6363
It then applies \pylint\ to a the selected set of files, using a reasonable default configuration.
64-
\Cref{exec:loops:for_loop_no_enumerate:pylint} is an example for the output of this \pgls{linter}.
64+
\Cref{exec:loops:for_loop_no_enumerate:pylint} is an example of the output of this \pgls{linter}.
6565

6666
\Cref{lst:bash:pytest} is similarly structured, but instead of performing \emph{static} code analysis, it executes unit test cases.
6767
The directory and list of \python\ files with the test cases are provided as command line arguments.

text/main/basics/collections/dictionaries/dictionaries.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
\label{sec:dictionaries}%
33
%
44
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{dicts_1.py}{--args format}{dicts:dicts_1}{%
5-
An example for using dictionaries in \python.}%
5+
An example of using dictionaries in \python.}%
66
%
77
Dictionaries in \python\ are containers that store key-value pairs.
88
The value associated with a given key is accessed via the \pythonil{[...]}\pythonIdx{[\idxdots]}-based indexing.

text/main/basics/collections/lists/lists.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
A first example for using lists in \python: creating, indexing, printing of and appending elements and other lists to lists.}%
1212
%
1313
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{lists_2.py}{--args format}{lists:lists_2}{%
14-
A second example for using lists in \python: inserting and deleting elements, sorting and reversing lists.}%
14+
A second example of using lists in \python: inserting and deleting elements, sorting and reversing lists.}%
1515
%
1616
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{lists_3.py}{--args format}{lists:lists_3}{%
17-
A third example for using lists in \python: slicing, adding, and multiplying lists.}%
17+
A third example of using lists in \python: slicing, adding, and multiplying lists.}%
1818
%
1919
In \cref{lst:lists:lists_1}, we provide some first examples for using lists.
2020
A list can be defined by simply writing its contents, separated by~\pythonilIdx{,} inside square brackets~\pythonil{[...]}\pythonIdx{[\idxdots]}.
@@ -140,7 +140,7 @@
140140
\FloatBarrier%
141141
\endhsection%
142142
%
143-
\hsection{An Example for Errors and a new Tool}%
143+
\hsection{An Example of Errors and a new Tool}%
144144
\label{sec:listExampleForErrorsAndRuff}%
145145
%
146146
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{lists_error.py}{--args format}{lists:lists_error}{%

text/main/basics/collections/sets/sets.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
\label{sec:sets}%
33
%
44
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{sets_1.py}{--args format}{sets:sets_1}{%
5-
A first example for using sets in \python: creating, modifying, and converting sets. %
5+
A first example of using sets in \python: creating, modifying, and converting sets. %
66
Since sets are unordered, printing them can yield a different result each time a program is executed (see \cref{bp:setsUnordered}).}%
77
%
88
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{sets_2.py}{--args format}{sets:sets_2}{%
9-
A second example for using sets in \python: creating sets and set operations (as illustrated in \cref{fig:setOperations}). %
9+
A second example of using sets in \python: creating sets and set operations (as illustrated in \cref{fig:setOperations}). %
1010
Since sets are unordered, printing them can yield a different result each time a program is executed (see \cref{bp:setsUnordered}).}%
1111
%
1212
\begin{figure}%
@@ -50,7 +50,7 @@
5050
If we have more than just very few elements and/or need to perform set operations such as those discussed in the following text, sets are the way to go.%
5151
%
5252
\begin{sloppypar}%
53-
In \cref{lst:sets:sets_1}, we provide a first example for creating and working with sets.
53+
In \cref{lst:sets:sets_1}, we provide a first example of creating and working with sets.
5454
Sets can be created by using curly braces, i.e, \pythonil{\{...\}}\pythonIdx{\textbraceleft\idxdots\textbraceright!set}.
5555
They can be type-hinted using the notation \pythonil{set[elementType]}\pythonIdx{set!type hint} where \pythonil{elementType} is the type of elements to be stored in the set~\cite{PEP585}.
5656
The line \pythonil{upper: set[str] = \{"A", "G", "B", "T", "V"\}} creates the variable \pythonil{upper}, which points to a set of the five uppercase latin characters~\pythonil{"A"}, \pythonil{"G"}, \pythonil{"B"}, \pythonil{"T"}, and~\pythonil{"V"}.

text/main/basics/collections/tuples/tuples.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
\label{sec:tuples}%
33
%
44
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{tuples_1.py}{--args format}{tuples:tuples_1}{%
5-
A first example for using tuples in \python: creating, indexing, and printing of tuples.}%
5+
A first example of using tuples in \python: creating, indexing, and printing of tuples.}%
66
%
77
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{02_collections}{tuples_2.py}{--args format}{tuples:tuples_2}{%
8-
A second example for using tuples in \python: tuples with elements of different types and tuple unpacking.}%
8+
A second example of using tuples in \python: tuples with elements of different types and tuple unpacking.}%
99
%
1010
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{02_collections}{tuples_3.py}{--args format}{tuples:tuples_3}{%
11-
A third example for using tuples in \python: testing the immutability property.}%
11+
A third example of using tuples in \python: testing the immutability property.}%
1212
%
1313
\gitOutputTool{\programmingWithPythonCodeRepo}{.}{scripts/mypy.sh 02_collections tuples_3.py}{tuples:tuples_3:mypy}{%
1414
The results of static type checking with \mypy\ of the program given in \cref{lst:tuples:tuples_3}.}%

text/main/basics/gettingStarted/pythonInTheTerminal/pythonInTheTerminal.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
\label{fig:terminalPython3result}%
2727
]{\includegraphics[width=0.9\linewidth]{\currentDir/terminalPython3result}}%
2828
%
29-
\caption{Example for executing a \python\ program in a \pgls{terminal} (on \ubuntu).}%
29+
\caption{Example of executing a \python\ program in a \pgls{terminal} (on \ubuntu).}%
3030
\label{fig:terminalPython}%
3131
\end{figure}%
3232
%

text/main/basics/simpleDataTypesAndOperations/float/float.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
They are off by \emph{less than~$10^{-15}$} so for all practical concerns, they are close enough.
135135
Sometimes, we even get the accurate result, e.g., when computing $\ln(e^{10})$ by evaluating \pythonil{log(e ** 10)}\pythonIdx{log}, which results in~\pythonil{10.0}.
136136

137-
As final example for floating point arithmetics, let us import the inverse trigonometric functions by doing \pythonil{from math import asin, acos, atan}\pythonIdx{math}\pythonIdx{asin}\pythonIdx{acos}\pythonIdx{atan}.
137+
As final example of floating point arithmetics, let us import the inverse trigonometric functions by doing \pythonil{from math import asin, acos, atan}\pythonIdx{math}\pythonIdx{asin}\pythonIdx{acos}\pythonIdx{atan}.
138138
Obviously, $\arcsin{\sin{0.925}}$ should be~$0.925$.
139139
Calculating \pythonil{asin(sin(0.925))}\pythonIdx{asin}\pythonIdx{sin} indeed yields~\pythonil{0.9250000000000002}.
140140
Due to the periodicity of the trigonometric functions, $\arccos{\cos{-0.3}}$ is~$0.3$ and \pythonil{acos(cos(-0.3))}\pythonIdx{acos}\pythonIdx{cos} results in~\pythonil{0.30000000000000016}.

text/main/basics/variables/assignment/assignment.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
You can define a variable and assign its value by writing \pythonil{name = value}.
66
Here, \pythonil{name} is the name of the variable and \pythonil{value} be the value that we want to assign to that name.%
77
%
8-
\hsection{A Simple Example for Variable Assignment and Comments in the Code}%
8+
\hsection{A Simple Example of Variable Assignment and Comments in the Code}%
99
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{01_variables}{assignment.py}{--args format}{variables:assignment}{%
1010
A \python\ program showing some examples for variable assignments.}%
1111
%

text/main/basics/variables/identity/identity.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
\end{figure}%
2222
%
2323
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{01_variables}{identity_1.py}{--args format}{variables:identity_1}{%
24-
An example for the difference between equality and identity\pythonIdx{sqrt}.}%
24+
An example of the difference between equality and identity\pythonIdx{sqrt}.}%
2525
%
2626
\gitPythonAndOutput{\programmingWithPythonCodeRepo}{01_variables}{identity_2.py}{--args format}{variables:identity_2}{%
27-
An second example for the difference between equality and identity.}%
27+
An second example of the difference between equality and identity.}%
2828
%
2929
We use variables to references objects in memory.
3030
When we compare two variables, we actually compare the objects they reference.
@@ -51,7 +51,7 @@
5151
If I would declare a variable \pythonil{d = a}, then \pythonil{d} would point to exactly the same \pythonil{float} object as~\pythonil{a}.
5252
Now, both \pythonil{a == b} and \pythonil{a is b} are \pythonil{True}.
5353

54-
A simple example for the difference between equality and identity is given in \cref{lst:variables:identity_1}.
54+
A simple example of the difference between equality and identity is given in \cref{lst:variables:identity_1}.
5555
Here, we declare a \pythonil{float} variable and store in it the value of~$\sqrt{2}$ (as exactly as it can be represented by a \python\ \pythonil{float}, that is), which just so happens to be \pythonil{1.4142135623730951}.
5656
We then import the function \pythonilIdx{sqrt} from the \pythonilIdx{math} module and compute~\pythonil{sqrt(2.0)}.
5757
We store the result of this in a second variable, namely \pythonil{sqrt_2_computed}.
@@ -66,7 +66,7 @@
6666
First-time readers are welcome to skip over the rest of this subsection.%
6767
}%
6868
%
69-
A slightly more involved example for the issue of object equality and identity is given in \cref{lst:variables:identity_2}.
69+
A slightly more involved example of the issue of object equality and identity is given in \cref{lst:variables:identity_2}.
7070
You see, when the \python\ interpreter parses the program code file, it will allocate the memory and store the values of constants and literals.
7171
\cref{lst:variables:identity_2}, we declare \pythonil{a = "Hello World!"} and then \pythonil{b = "Hello World!"}.
7272
In other words, \pythonil{a} and \pythonil{b} will receive the same value.

0 commit comments

Comments
 (0)