Skip to content

Commit 2656578

Browse files
Close file descriptor when no longer needed.
1 parent 7ed2f9f commit 2656578

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pywavefront/parser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ class Parser(object):
4242
strict = False
4343

4444
def read_file(self, file_name):
45-
for line in open(file_name, 'r'):
46-
self.parse(line, dir=os.path.dirname(file_name))
45+
with open(file_name, 'r') as file:
46+
for line in file:
47+
self.parse(line, dir=os.path.dirname(file_name))
4748

4849
def parse(self, line, dir):
4950
"""Determine what type of line we are and dispatch

0 commit comments

Comments
 (0)