diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-12-08 15:59:58 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-12-08 15:59:58 (GMT) |
commit | d9569fa90d9046f9019fe8e89dacc7c4d886e529 (patch) | |
tree | 8f9aa5192dccb48494bdb5893f898207c0b5ab54 /Doc/tutorial | |
parent | 0c1034f41964140624e8579077c2aa328a440558 (diff) | |
parent | a7129d38edb1a9db17fbd8b40d9eaf135a857f8e (diff) | |
download | cpython-d9569fa90d9046f9019fe8e89dacc7c4d886e529.zip cpython-d9569fa90d9046f9019fe8e89dacc7c4d886e529.tar.gz cpython-d9569fa90d9046f9019fe8e89dacc7c4d886e529.tar.bz2 |
Drop double newlines printed in some file iteration examples.
Patch by Steven Kryskalla.
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/errors.rst | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst index 53be499..2b76c32 100644 --- a/Doc/tutorial/errors.rst +++ b/Doc/tutorial/errors.rst @@ -387,7 +387,7 @@ succeeded or failed. Look at the following example, which tries to open a file 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 @@ used in a way that ensures they are always cleaned up promptly and correctly. :: 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, |