# HG changeset patch # User Steven Kryskalla # Date 1354503917 28800 # Node ID e2305f983e0825644e893d8f691e243ca2febc34 # Parent 31d6da06a899a266d9d58f9377d4102e42143197 Doc fixes for looping over a file's lines Fixed 4 places in the docs where double newlines were being printed when looping over a file line-by-line. diff -r 31d6da06a899 -r e2305f983e08 Doc/tutorial/errors.rst --- a/Doc/tutorial/errors.rst Sun Dec 02 12:37:09 2012 -0500 +++ b/Doc/tutorial/errors.rst Sun Dec 02 19:05:17 2012 -0800 @@ -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, diff -r 31d6da06a899 -r e2305f983e08 Doc/whatsnew/2.5.rst --- a/Doc/whatsnew/2.5.rst Sun Dec 02 12:37:09 2012 -0500 +++ b/Doc/whatsnew/2.5.rst Sun Dec 02 19:05:17 2012 -0800 @@ -598,7 +598,7 @@ with open('/etc/passwd', 'r') as f: for line in f: - print line + print line, ... more processing code ... After this statement has executed, the file object in *f* will have been diff -r 31d6da06a899 -r e2305f983e08 Doc/whatsnew/2.6.rst --- a/Doc/whatsnew/2.6.rst Sun Dec 02 12:37:09 2012 -0500 +++ b/Doc/whatsnew/2.6.rst Sun Dec 02 19:05:17 2012 -0800 @@ -286,7 +286,7 @@ with open('/etc/passwd', 'r') as f: for line in f: - print line + print line, ... more processing code ... After this statement has executed, the file object in *f* will have been