Skip to content

Commit 1f8cefe

Browse files
committed
more improvements and bugfixes
1 parent 9e5dd52 commit 1f8cefe

File tree

7 files changed

+32
-14
lines changed

7 files changed

+32
-14
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
\listingPythonAndOutput{tuples:tuples_2}{tuples_2.py}{%
1010
A second example of using tuples in \python:~tuples with elements of different types and tuple unpacking.}{}%
1111
%
12-
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{collections}{tuples_3.py}{--args format}{tuples:tuples_3}{%
12+
\gitLoadAndExecPythonAndErrors{tuples:tuples_3}{}{collections}{tuples_3.py}{}%
13+
\listingPythonAndError{tuples:tuples_3}{tuples_3.py}{%
1314
A third example of using tuples in \python:~testing the immutability property.}%
1415
%
1516
\gitExec{exec:tuples:tuples_3:mypy}{\programmingWithPythonCodeRepo}{.}{_scripts_/mypy.sh collections tuples_3.py}%

text/main/basics/variables/errorsInIde/errorsInIde.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
\hsection{Interlude: Finding Errors in your Code with the IDE}%
22
\label{sec:errorsInIde}%
33
%
4-
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{variables}{assignment_wrong.py}{--args format}{variables:assignment_wrong}{%
5-
A variant of \cref{lst:variables:assignment} with an error: \pythonil{int_var} is accidentally spelled as \pythonil{intvar} in one location.}%
4+
\gitLoadAndExecPythonAndErrors{variables:assignment_wrong}{}{variables}{assignment_wrong.py}{}%
5+
\listingPythonAndError{variables:assignment_wrong}{assignment_wrong.py}{%
6+
A variant of \cref{lst:variables:assignment} with an error:~\pythonil{int_var} is accidentally spelled as \pythonil{intvar} in one location.}%
67
%
78
\begin{figure}%
89
\centering%

text/main/controlFlow/exceptions/exceptions.tex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@
114114
\listingPython{exceptions:sqrt_raise}{%
115115
A new variant of the \pythonil{sqrt} function from back in \cref{lst:functions:my_math_2} that raises an \pythonilIdx{ArithmeticError} if its input is non-finite or negative.}%
116116
%
117-
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{exceptions}{use_sqrt_raise.py}{--args format}{exceptions:use_sqrt_raise}{%
117+
\gitLoadAndExecPythonAndErrors{exceptions:use_sqrt_raise}{}{exceptions}{use_sqrt_raise.py}{}%
118+
\listingPythonAndError{exceptions:use_sqrt_raise}{use_sqrt_raise.py}{%
118119
Using the new variant of the \pythonil{sqrt} function from \cref{lst:exceptions:sqrt_raise} that raises an \pythonilIdx{ArithmeticError} if its input is non-finite or negative.}%
119120
%
120121
Let us now first look at an example of how we can signal an error condition in our code.
@@ -298,7 +299,8 @@
298299
The \pythonilIdx{except} block is not to be used to just catch any exception, to implement \gls{GIGO}, or to try to sanitize erroneous input.%
299300
}%
300301
%
301-
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{exceptions}{try_multi_except.py}{--args format}{exceptions:try_multi_except}{%
302+
\gitLoadAndExecPythonAndErrors{exceptions:try_multi_except}{}{exceptions}{try_multi_except.py}{}%
303+
\listingPythonAndError{exceptions:try_multi_except}{try_multi_except.py}{%
302304
The handling of multiple errors, namely \pythonilIdx{ZeroDivisionError} and \pythonilIdx{ArithmeticError}, as well as what happens if a variable remains unassigned due to an error (a \pythonilIdx{NameError} is raised).}%
303305
%
304306
In \cref{lst:exceptions:try_multi_except}, we revisit our new \pythonil{sqrt} function.
@@ -341,7 +343,8 @@
341343
%
342344
\hsection{Exceptions in Exception Handlers}%
343345
%
344-
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{exceptions}{try_except_nested_1.py}{--args format}{exceptions:try_except_nested_1}{%
346+
\gitLoadAndExecPythonAndErrors{exceptions:try_except_nested_1}{}{exceptions}{try_except_nested_1.py}{}%
347+
\listingPythonAndError{exceptions:try_except_nested_1}{try_except_nested_1.py}{%
345348
An example of \pythonils{Exception} being raised inside an \pythonilIdx{except} block.}%
346349
%
347350
What happens if an exception is raised \emph{inside} an \pythonilIdx{except} block?
@@ -445,7 +448,8 @@
445448
next statement # Executed only if there are no uncaught Exceptions.
446449
\end{pythonSyntax}
447450
%
448-
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{exceptions}{try_except_else_finally.py}{--args format}{exceptions:try_except_else_finally}{%
451+
\gitLoadAndExecPythonAndErrors{exceptions:try_except_else_finally}{}{exceptions}{try_except_else_finally.py}{}%
452+
\listingPythonAndError{exceptions:try_except_else_finally}{try_except_else_finally.py}{%
449453
An example for the \pythonilIdx{try}-\pythonilIdx{except}-\pythonilIdx{else}-\pythonilIdx{finally} block.}%
450454
%
451455
\gitExec{exec:exceptions:try_except_else_finally:mypy}{\programmingWithPythonCodeRepo}{.}{_scripts_/mypy.sh exceptions try_except_else_finally.py}%

text/main/controlFlow/iteration/iteration.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@
498498
In our example program, we stop here.
499499
This means that the 999'999'996 elements are never created.
500500

501-
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{iteration}{generator_expressions_next_2.py}{--args format}{iteration:generator_expressions_next_2}{%
501+
\gitLoadAndExecPythonAndErrors{iteration:generator_expressions_next_2}{}{iteration}{generator_expressions_next_2.py}{}%
502+
\listingPythonAndError{iteration:generator_expressions_next_2}{generator_expressions_next_2.py}{%
502503
An investigation of the lazy evaluation in generator expressions\pythonIdx{Generator} by using the \pythonilIdx{next} function.}%
503504
\afterpage{\clearpage}%
504505
%
@@ -646,7 +647,8 @@
646647
%
647648
\hsection{Generator Functions}%
648649
%
649-
\gitPythonAndErrorOutput{\programmingWithPythonCodeRepo}{iteration}{simple_generator_function_1.py}{--args format}{iteration:simple_generator_function_1}{%
650+
\gitLoadAndExecPythonAndErrors{iteration:simple_generator_function_1}{}{iteration}{simple_generator_function_1.py}{}%
651+
\listingPythonAndError{iteration:simple_generator_function_1}{simple_generator_function_1.py}{%
650652
A very simple generator function yielding the numbers~1, 2, and~3\pythonIdx{Generator}.}%
651653
%
652654
\gitLoadAndExecPython{iteration:simple_generator_function_2}{}{iteration}{simple_generator_function_2.py}{}%

text/main/ecosystem/packages/pipAndVenv/pipAndVenv.tex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@
7474
After \aptGet\ completes, we can check the version of \pip\ via \bashil{pip --version}.
7575
Whether \venv\ is installed correctly can be checked via \bashil{python3 -m venv -h}.
7676

77-
\gitBashAndOutput{\programmingWithPythonCodeRepo}{packages}{numpy_user_venv.sh}{packages:numpy_user_venv_sh}{%
78-
An example of using \pglspl{virtualEnvironment} and \pip\ under \ubuntu\ \linux\ to install \numpy\ and to run our program \cref{lst:packages:numpy_user}.}%
77+
\gitLoad{lst:packages:numpy_user_venv_sh}{\programmingWithPythonCodeRepo}{packages/numpy_user_venv.sh}{}%
78+
\gitExecBash{exec:packages:numpy_user_venv_sh}{\programmingWithPythonCodeRepo}{packages}{numpy_user_venv.sh}
79+
\listingDoubleBox{packages:numpy_user_venv_sh}{%
80+
An example of using \pglspl{virtualEnvironment} and \pip\ under \ubuntu\ \linux\ to install \numpy\ and to run our program \cref{lst:packages:numpy_user}.}{%
81+
\captionStdout{packages:numpy_user}{numpy_user_venv.sh}}{%
82+
,style=bash_style}{,style=text_style}{%
83+
\listingSepBash{numpy_user_venv.sh}}%
7984
%
8085
\begin{figure}%
8186
\centering%

text/main/ecosystem/packages/requirementsFiles/requirementsFiles.tex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
\listingTxt{packages:requirementstxt}{%
77
A requirements file demanding that version~\textil{1.26.4} of \numpy\ be installed.}%
88
%
9-
\gitBashAndOutput{\programmingWithPythonCodeRepo}{packages}{numpy_user_venv_req.sh}{packages:numpy_user_venv_req_sh}{%
10-
A script that runs our example program using a \pgls{virtualEnvironment} created by using the \textil{requirements.txt} file given in \cref{lst:packages:requirementstxt}.}%
9+
\gitLoad{lst:packages:numpy_user_venv_req_sh}{\programmingWithPythonCodeRepo}{packages/numpy_user_venv_req.sh}{}%
10+
\gitExecBash{exec:packages:numpy_user_venv_req_sh}{\programmingWithPythonCodeRepo}{packages}{numpy_user_venv_req.sh}
11+
\listingDoubleBox{packages:numpy_user_venv_req_sh}{%
12+
A script that runs our example program using a \pgls{virtualEnvironment} created by using the \textil{requirements.txt} file given in \cref{lst:packages:requirementstxt}.}{%
13+
\captionStdout{packages:numpy_user_venv_req_sh}{numpy_user_venv_req.sh}}{%
14+
,style=bash_style}{,style=text_style}{%
15+
\listingSepBash{numpy_user_venv_req.sh}}%
1116
%
1217
It is very normal that our projects require multiple different \pglspl{package}.
1318
Sometimes, they require specific versions of specific \pglspl{package}.

0 commit comments

Comments
 (0)