modernize some modules' code by using with statement around open()

This commit is contained in:
Giampaolo Rodola' 2013-02-12 02:04:27 +01:00
parent fd6e6cfa29
commit 2f50aaf2ff
14 changed files with 50 additions and 89 deletions

View file

@ -77,10 +77,9 @@ class Profile(_lsprof.Profiler):
def dump_stats(self, file):
import marshal
f = open(file, 'wb')
self.create_stats()
marshal.dump(self.stats, f)
f.close()
with open(file, 'wb') as f:
self.create_stats()
marshal.dump(self.stats, f)
def create_stats(self):
self.disable()