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()
|
fw.close()
|
||||||
|
|
||||||
def parse_file(filename):
|
def parse_file(filename):
|
||||||
try:
|
with open(filename,'rb') as fr:
|
||||||
fr = open(filename,'rb')
|
|
||||||
content = fr.readlines()
|
content = fr.readlines()
|
||||||
finally:
|
|
||||||
fr.close()
|
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
retval=[]
|
retval=[]
|
||||||
|
|
Loading…
Reference in a new issue