From d02e78f639f04f3e2395a29ed94e8cf2d56f23d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2EYasoob=20Ullah=20Khalid=20=E2=98=BA?= Date: Sun, 1 Dec 2013 00:40:10 +0500 Subject: [PATCH] using with construct using with construct so that the file closes smoothly --- hackertray/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hackertray/__init__.py b/hackertray/__init__.py index e0fbe62..78f92b5 100644 --- a/hackertray/__init__.py +++ b/hackertray/__init__.py @@ -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):