Why use 'with' when working with files?

Why use 'with' when working with files?



Answer: It creates a temp file object that's only live during the indented scope, and is closed automatically, even if there's an exception that kicks you out of that scope.


Learn More :