Use a with-block to close files
@mrnarwhal55▲ 5 net votes
with open(path) as f: closes the file even if an exception is raised inside the block.
5 COMMENTS
Fundamental
Solid
Actionable
Goldmine
Superb
with open(path) as f: closes the file even if an exception is raised inside the block.
Fundamental
Solid
Actionable
Goldmine
Superb