--- doanddont.rst 2010-04-24 20:47:40.000000000 +0200 +++ doanddont.rst.modified 2010-04-24 20:54:03.747356164 +0200 @@ -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