| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -387,7 +387,7 @@ succeeded or failed. Look at the following example, which tries to open a file | |||
| 387 | 387 | and print its contents to the screen. :: | |
| 388 | 388 | ||
| 389 | 389 | for line in open("myfile.txt"): | |
| 390 | - print(line) | ||
| 390 | + print(line, end="") | ||
| 391 | 391 | ||
| 392 | 392 | The problem with this code is that it leaves the file open for an indeterminate | |
| 393 | 393 | 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. :: | |||
| 397 | 397 | ||
| 398 | 398 | with open("myfile.txt") as f: | |
| 399 | 399 | for line in f: | |
| 400 | - print(line) | ||
| 400 | + print(line, end="") | ||
| 401 | 401 | ||
| 402 | 402 | After the statement is executed, the file *f* is always closed, even if a | |
| 403 | 403 | problem was encountered while processing the lines. Objects which, like files, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -592,6 +592,7 @@ Cédric Krier | |||
| 592 | 592 | Hannu Krosing | |
| 593 | 593 | Andrej Krpic | |
| 594 | 594 | Ivan Krstić | |
| 595 | + Steven Kryskalla | ||
| 595 | 596 | Andrew Kuchling | |
| 596 | 597 | Dave Kuhlman | |
| 597 | 598 | Vladimir Kushnir | |
| Back | FazBrowse Home | New Git URL |
0 commit comments