diff Doc/tutorial/errors.rst @ 80755:fed7306f26ce 3.2

Drop double newlines printed in some file iteration examples. Patch by Steven Kryskalla.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Sat, 08 Dec 2012 17:59:03 +0200
parents fa91270b6087
children 32689671a881
line wrap: on
line diff
--- a/Doc/tutorial/errors.rst	Sat Dec 08 12:29:40 2012 +0200
+++ b/Doc/tutorial/errors.rst	Sat Dec 08 17:59:03 2012 +0200
@@ -387,7 +387,7 @@
 and print its contents to the screen. ::
 
    for line in open("myfile.txt"):
-       print(line)
+       print(line, end="")
 
 The problem with this code is that it leaves the file open for an indeterminate
 amount of time after this part of the code has finished executing.
@@ -397,7 +397,7 @@
 
    with open("myfile.txt") as f:
        for line in f:
-           print(line)
+           print(line, end="")
 
 After the statement is executed, the file *f* is always closed, even if a
 problem was encountered while processing the lines. Objects which, like files,