classification
Title: Reorder 'with' statement for files in Python Tutorial
Type: enhancement Stage: needs patch
Components: Documentation Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: ezio.melotti, georg.brandl, jjalocha
Priority: low Keywords:

Created on 2009-07-19 01:19 by jjalocha, last changed 2010-10-29 10:07 by admin.

Messages (2)
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) * (Python committer) 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.
History
Date User Action Args
2010-10-29 10:07:21adminsetassignee: georg.brandl -> docs@python
2010-08-07 21:28:34terry.reedysetversions: - Python 2.6
2010-02-27 09:48:49ezio.melottisetstage: needs patch
messages: + msg100179
versions: - Python 3.0
2009-08-10 11:49:32ezio.melottisetpriority: low
nosy: + ezio.melotti
2009-07-19 01:19:28jjalochacreate