close file handle

master
Micke Nordin 7 years ago
parent 1f27fb19d4
commit 259dc86722

@ -26,16 +26,17 @@ class Board():
return string[:-2] return string[:-2]
def from_file(self, file_name): def from_file(self, file_name):
self.save_file = open(file_name,'r') save_file = open(file_name,'r')
rowc = 0 rowc = 0
board = [] board = []
for row in self.save_file: for row in save_file:
board.append([]) board.append([])
cellc = 0 cellc = 0
for cell in row[:-1]: for cell in row[:-1]:
board[rowc].append( Cell(rowc,cellc,bool(int(cell))) ) board[rowc].append( Cell(rowc,cellc,bool(int(cell))) )
cellc = cellc + 1 cellc = cellc + 1
rowc = rowc + 1 rowc = rowc + 1
save_file.close()
return matrix(board) return matrix(board)
def get_neighbours(self, cell): def get_neighbours(self, cell):

Loading…
Cancel
Save