3 ms·
Which of these forms you use does not matter all that much. They both have the same semantics where a file is opened, and it is up to the programmer to remember
by alephnil 8y ago
Which of these forms you use does not matter all that much. They both have the same semantics where a file is opened, and it is up to the programmer to remember to close it. What actually is a an improvement is Common Lisp's with-open-file or similarly, python's with:
with open("somefile.dat", "wb") as f:
f.write(somevar)
which automatically closes the file when it leaves the scope.