Skip to content

Commit f176dd0

Browse files
committed
context manager for file handling changed too in from_file function
1 parent 466d992 commit f176dd0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

data_structures/arrays/sudoku_solver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ def unitsolved(unit):
171171

172172
def from_file(filename, sep="\n"):
173173
"Parse a file into a list of strings, separated by sep."
174-
return open(filename).read().strip().split(sep)
174+
with open(filename) as file:
175+
return file.read().strip().split(sep)
175176

176177

177178
def random_puzzle(assignments=17):

0 commit comments

Comments
 (0)