From f11d4e43ef303c6ac8288d5c77198776c38cf3f0 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 14 Aug 2012 17:12:15 -0400 Subject: [PATCH] cc-4105: improved index file creation method to use 'with' statement --- python_apps/media-monitor2/mm2.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python_apps/media-monitor2/mm2.py b/python_apps/media-monitor2/mm2.py index ef3b78852..a8a3dfb26 100644 --- a/python_apps/media-monitor2/mm2.py +++ b/python_apps/media-monitor2/mm2.py @@ -57,9 +57,7 @@ def main(global_config, api_client_config, log_config, if not os.path.exists(config['index_path']): log.info("Attempting to create index file:...") try: - f = open(config['index_path']) - f.write(" ") - f.close() + with open(config['index_path']) as f: f.write(" ") except Exception as e: log.info("Failed to create index file with exception: %s" % str(e)) else: