python: use a with-statement to manage file close
This commit is contained in:
parent
7714abd56e
commit
22e9d0e2f1
1 changed files with 1 additions and 4 deletions
|
@ -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=[]
|
||||
|
|
Loading…
Reference in a new issue