Closed orbeckst closed 6 years ago
Use a context manager (with the with statement) to open files: https://github.com/tunaLandslide/HonorsContract/blob/7d98ccf87a8593f45be11f56e839f2aecfb3c598/mchain.py#L5
with
with open(file, 'r') as tex: ref = tex.read().split()
and tex.close() is not needed. See footnote on HW4, problem 4.4 in assignment_04.pdf
tex.close()
Btw, the same trick works for all other cases where you open a file.
open
Use a context manager (with the
with
statement) to open files: https://github.com/tunaLandslide/HonorsContract/blob/7d98ccf87a8593f45be11f56e839f2aecfb3c598/mchain.py#L5and
tex.close()
is not needed. See footnote on HW4, problem 4.4 in assignment_04.pdf