[Python-checkins] r80461 - python/trunk/Doc/howto/doanddont.rst

georg.brandl python-checkins at python.org
Sun Apr 25 12:17:27 CEST 2010


Author: georg.brandl
Date: Sun Apr 25 12:17:27 2010
New Revision: 80461

Log:
#8522: use with statement instead of try-finally for file handling.

Modified:
   python/trunk/Doc/howto/doanddont.rst

Modified: python/trunk/Doc/howto/doanddont.rst
==============================================================================
--- python/trunk/Doc/howto/doanddont.rst	(original)
+++ python/trunk/Doc/howto/doanddont.rst	Sun Apr 25 12:17:27 2010
@@ -232,11 +232,8 @@
 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


More information about the Python-checkins mailing list