Skip to content

Handle files with context managers (i.e. `with` keyword)

I count 27 places where files are opened and closed directly using open and close. These cases are better handled using context management. i.e. with open(...) as f: ..., which are more idiomatic and handle errors better.