Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a6e16a8

Browse files
committed
Replace all cases of "while 1" with "while True".
Though slightly slower, has better clarity and teaching value.
1 parent 80d21af commit a6e16a8

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

Doc/tut/tut.tex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ \section{\keyword{pass} Statements \label{pass}}
12151215
For example:
12161216

12171217
\begin{verbatim}
1218-
>>> while 1:
1218+
>>> while True:
12191219
... pass # Busy-wait for keyboard interrupt
12201220
...
12211221
\end{verbatim}
@@ -1358,7 +1358,7 @@ \subsection{Default Argument Values \label{defaultArgs}}
13581358

13591359
\begin{verbatim}
13601360
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
1361-
while 1:
1361+
while True:
13621362
ok = raw_input(prompt)
13631363
if ok in ('y', 'ye', 'yes'): return 1
13641364
if ok in ('n', 'no', 'nop', 'nope'): return 0
@@ -3076,10 +3076,10 @@ \section{Syntax Errors \label{syntaxErrors}}
30763076
kind of complaint you get while you are still learning Python:
30773077
30783078
\begin{verbatim}
3079-
>>> while 1 print 'Hello world'
3079+
>>> while True print 'Hello world'
30803080
File "<stdin>", line 1, in ?
3081-
while 1 print 'Hello world'
3082-
^
3081+
while True print 'Hello world'
3082+
^
30833083
SyntaxError: invalid syntax
30843084
\end{verbatim}
30853085
@@ -3149,7 +3149,7 @@ \section{Handling Exceptions \label{handling}}
31493149
raising the \exception{KeyboardInterrupt} exception.
31503150
31513151
\begin{verbatim}
3152-
>>> while 1:
3152+
>>> while True:
31533153
... try:
31543154
... x = int(raw_input("Please enter a number: "))
31553155
... break
@@ -3760,7 +3760,7 @@ \subsection{Method Objects \label{methodObjects}}
37603760
37613761
\begin{verbatim}
37623762
xf = x.f
3763-
while 1:
3763+
while True:
37643764
print xf()
37653765
\end{verbatim}
37663766

0 commit comments

Comments
 (0)