Merged revisions 80461 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r80461 | georg.brandl | 2010-04-25 12:17:27 +0200 (So, 25 Apr 2010) | 1 line

  #8522: use with statement instead of try-finally for file handling.
........
This commit is contained in:
Georg Brandl 2010-04-25 10:18:59 +00:00
parent c689d96044
commit a33971a395
1 changed files with 1 additions and 4 deletions

View File

@ -232,11 +232,8 @@ file would not be closed when an exception is raised until the handler finishes,
and perhaps not at all in non-C implementations (e.g., Jython). ::
def get_status(file):
fp = open(file)
try:
with open(file) as fp:
return fp.readline()
finally:
fp.close()
Using the Batteries