msg90698 - (view) |
Author: Jerzy Jalocha N (jjalocha) |
Date: 2009-07-19 01:19 |
Actually, the Python Tutorial recommends the use of the 'with' statement in Section 7.2.1. "Methods of File Objects": > It is good practice to use the with keyword when dealing with file > objects. [etc.] But the example and description are at the very bottom of this very large section, and are easily missed by new Python users. If this suggestion is to be taken seriously, I suggest putting this information at a more prominent place, somewhere at the top of the short section 7.2. "Reading and Writing Files". |
|
|
msg100179 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2010-02-27 09:48 |
All the examples there assume that "a file object called f has already been created". Using a 'with' there it's not a good idea because the users will have to keep the instructions indented under the 'with'. However I agree that it would be better to move that example earlier. Maybe in 7.2 both the forms can be shown and discussed briefly. |
|
|
msg280167 - (view) |
Author: A.M. Kuchling (akuchling) *  |
Date: 2016-11-06 19:44 |
Good suggestion -- here's a patch that moves it and rewrites a little. |
|
|
msg280208 - (view) |
Author: Berker Peksag (berker.peksag) *  |
Date: 2016-11-07 16:41 |
The patch looks good to me. I think we can tweak the content a bit. I left some comments on Rietveld. Thanks! |
|
|
msg295825 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2017-06-12 20:43 |
@akuchling Can you prepare a PR on GitHub? |
|
|
msg295832 - (view) |
Author: A.M. Kuchling (akuchling) *  |
Date: 2017-06-13 01:11 |
PR filed against master: https://github.com/python/cpython/pull/2143 |
|
|
msg295847 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2017-06-13 05:31 |
New changeset bd4e9e0ca96dabf33605d9b1fd1e0562ece8ae18 by Mariatta (Andrew Kuchling) in branch 'master': bpo-6519: Improve Python Input Output Tutorial (GH-2143) https://github.com/python/cpython/commit/bd4e9e0ca96dabf33605d9b1fd1e0562ece8ae18 |
|
|
msg295848 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2017-06-13 05:40 |
New changeset 81c05ccc10d044584dff3a69ee531094ed76ee2c by Mariatta in branch '3.6': bpo-6519: Improve Python Input Output Tutorial (GH-2143) (GH-2145) https://github.com/python/cpython/commit/81c05ccc10d044584dff3a69ee531094ed76ee2c |
|
|
msg295849 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2017-06-13 05:40 |
New changeset 5a86154a931083e6a9f9bdf9cc8b3bc33abb673d by Mariatta in branch '3.5': bpo-6519: Improve Python Input Output Tutorial (GH-2143) (GH-2146) https://github.com/python/cpython/commit/5a86154a931083e6a9f9bdf9cc8b3bc33abb673d |
|
|
msg295850 - (view) |
Author: Mariatta (Mariatta) *  |
Date: 2017-06-13 05:43 |
Thanks everyone! I merged the PR and backported to 3.6 and 3.5. There are a bunch of conflicts when trying to backport to 2.7, so I decided not to bother. |
|
|