[Tutor] Why do you have to close files?

Stefan Behnel stefan_ml at behnel.de
Fri Jan 27 08:54:16 CET 2012


Alan Gauld, 27.01.2012 02:16:
> with open(myfile) as aFile:
>      # use aFile

I should add that this is the shortest, safest (as in "hard to get wrong")
and most readable way to open and close a file. It's worth getting used to.

Stefan



More information about the Tutor mailing list