Skip to content

Commit 17cad53

Browse files
committed
slight improvement
1 parent f05b948 commit 17cad53

File tree

1 file changed

+6
-4
lines changed
  • text/main/basics/simpleDataTypesAndOperations/str

1 file changed

+6
-4
lines changed

text/main/basics/simpleDataTypesAndOperations/str/str.tex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,16 @@
335335

336336
You see, in \python, we can test many objects for their truth value.
337337
\pythonilIdx{True} and \pythonil{False} obviously have truth values \pythonilIdx{True} and \pythonilIdx{False}, respectively.
338-
By default, other objects have truth value \pythonilIdx{True} unless it offers an explicit conversion to \pythonilIdx{bool}\footnote{%
338+
By default, another object has truth value \pythonilIdx{True} unless it offers an explicit conversion to \pythonilIdx{bool}\footnote{%
339339
Via the dunder method \dunder{bool}, see later in \cref{sec:dunderMethodsOverview}.} %
340340
that yields~\pythonilIdx{False} or has a length and that length is zero\footnote{%
341341
Via the dunder method \dunder{len}, see later in \cref{sec:dunderMethodsOverview}.}.
342-
Other objects that have a truth value of \pythonilIdx{False} are numeric types which are zero, such as \pythonil{0} and \pythonil{0.0} as well as empty collections~(which we learn about a bit later in \cref{sec:collections}).
343-
Now, \pythonil{\"False\"} is not empty, i.e., has a length greater than~0.
342+
Other objects that have a truth value of \pythonilIdx{False} are numeric types which are zero, such as \pythonil{0} and \pythonil{0.0} as well as empty collections~(which we learn about a bit later in \cref{sec:collections}) or the empty string.
343+
Now, \pythonil{\"False\"} is not an empty string.
344+
It has a length greater than~0.
344345
Therefore, it has truth value \pythonilIdx{True}, meaning that \pythonil{bool(\"False\")}\pythonIdx{bool({\textquotedbl}False{\textquotedbl})} actually yields \pythonilIdx{True}!
345-
The empty string, on the other hand, has a truth value of \pythonilIdx{False}, i.e., \pythonil{bool(\"\")}\pythonIdx{bool(\textquotedbl\textquotedbl)} gives us \pythonilIdx{False}.
346+
The empty string, on the other hand, has lengh zero.
347+
Therefore, it has a truth value of \pythonilIdx{False}, i.e., \pythonil{bool(\"\")}\pythonIdx{bool(\textquotedbl\textquotedbl)} gives us \pythonilIdx{False}.
346348

347349
It should be noted that these conversion functions also work with other datatypes.
348350
For example, \pythonil{float(0)} converts the integer~\pythonil{0} to the \pythonil{float} value~\pythonil{0.0} and \pythonilIdx{bool(0)} gives us \pythonilIdx{False}.

0 commit comments

Comments
 (0)