using with construct

using with construct so that the file closes smoothly
This commit is contained in:
M.Yasoob Ullah Khalid ☺ 2013-12-01 00:40:10 +05:00
parent fa630d776e
commit d02e78f639
1 changed files with 2 additions and 2 deletions

View File

@ -72,8 +72,8 @@ class HackerNewsApp:
l=list(self.db)
home = expanduser("~")
#truncate the file
file = open(home+'/.hackertray.json', 'w+')
file.write(json.dumps(l))
with open(home+'/.hackertray.json', 'w+') as file:
file.write(json.dumps(l))
gtk.main_quit()
def run(self):