Use with block to open file
This commit is contained in:
parent
0778be30a1
commit
c4da4bdcb6
@ -40,9 +40,8 @@ tests_path = 'test/'
|
|||||||
|
|
||||||
def readfile(fname):
|
def readfile(fname):
|
||||||
'''Reads a file as string and returns its content'''
|
'''Reads a file as string and returns its content'''
|
||||||
fd = open(fname, encoding='utf-8')
|
with open(fname, encoding='utf-8') as fd:
|
||||||
expr = fd.read()
|
expr = fd.read()
|
||||||
fd.close()
|
|
||||||
return expr
|
return expr
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user