Skip to content

Commit 0c7b7b2

Browse files
authored
Update book.tex
Universal newlines in Python 3
1 parent 0382071 commit 0c7b7b2

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

book/book.tex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ \section*{Contributor List}
718718

719719
\item William Murray corrected my definition of floor division.
720720

721+
\item Per Starb{\"a}ck brought me up to date on universal newlines in Python 3.
722+
721723
% ENDCONTRIB
722724

723725
In addition, people who spotted typos or made corrections include
@@ -6856,25 +6858,24 @@ \section{Reading word lists}
68566858

68576859
\begin{verbatim}
68586860
>>> fin.readline()
6859-
'aa\r\n'
6861+
'aa\n'
68606862
\end{verbatim}
68616863
%
68626864
The first word in this particular list is ``aa'', which is a kind of
6863-
lava. The sequence \verb"\r\n" represents two whitespace characters,
6864-
a carriage return and a newline, that separate this word from the
6865-
next.
6865+
lava. The sequence \verb"\n" represents the newline character that
6866+
separates this word from the next.
68666867

68676868
The file object keeps track of where it is in the file, so
68686869
if you call {\tt readline} again, you get the next word:
68696870

68706871
\begin{verbatim}
68716872
>>> fin.readline()
6872-
'aah\r\n'
6873+
'aah\n'
68736874
\end{verbatim}
68746875
%
68756876
The next word is ``aah'', which is a perfectly legitimate
68766877
word, so stop looking at me like that.
6877-
Or, if it's the whitespace that's bothering you,
6878+
Or, if it's the newline character that's bothering you,
68786879
we can get rid of it with the string method {\tt strip}:
68796880
\index{strip method}
68806881
\index{method!strip}

0 commit comments

Comments
 (0)