From 22e9d0e2f176e029ce55dcbbaeb89bd9bbdf76ad Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Thu, 1 Oct 2020 22:51:31 -0500 Subject: [PATCH] python: use a with-statement to manage file close --- scripts/python/nasal_api_doc.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/python/nasal_api_doc.py b/scripts/python/nasal_api_doc.py index b7eaa6251..f8748e710 100755 --- a/scripts/python/nasal_api_doc.py +++ b/scripts/python/nasal_api_doc.py @@ -151,11 +151,8 @@ def output_text(top_namespaces,modules,version): fw.close() def parse_file(filename): - try: - fr = open(filename,'rb') + with open(filename,'rb') as fr: content = fr.readlines() - finally: - fr.close() i=0 retval=[]