summaryrefslogtreecommitdiffstats
path: root/Doc/howto/doanddont.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-04-25 10:19:53 (GMT)
committerGeorg Brandl <georg@python.org>2010-04-25 10:19:53 (GMT)
commit386bc6d38099d9e1f378d3e97654093bb9becbd9 (patch)
treee69b8b9e44ece6e8434f068e55f90aa52bfb7205 /Doc/howto/doanddont.rst
parent7f810cd91576ad43babdbd94647ceda613024fbb (diff)
downloadcpython-386bc6d38099d9e1f378d3e97654093bb9becbd9.zip
cpython-386bc6d38099d9e1f378d3e97654093bb9becbd9.tar.gz
cpython-386bc6d38099d9e1f378d3e97654093bb9becbd9.tar.bz2
Merged revisions 80150,80460-80461 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80150 | r.david.murray | 2010-04-17 17:45:38 +0200 (Sa, 17 Apr 2010) | 2 lines Update link to Apple Publication Style guide. ........ r80460 | georg.brandl | 2010-04-25 12:16:00 +0200 (So, 25 Apr 2010) | 1 line #8528: fix typo. ........ 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. ........
Diffstat (limited to 'Doc/howto/doanddont.rst')
-rw-r--r--Doc/howto/doanddont.rst5
1 files changed, 1 insertions, 4 deletions
diff --git a/Doc/howto/doanddont.rst b/Doc/howto/doanddont.rst
index a9302ed..071eb2a 100644
--- a/Doc/howto/doanddont.rst
+++ b/Doc/howto/doanddont.rst
@@ -199,11 +199,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