[pypy-dev] close your files
Laura Creighton
lac at openend.se
Wed Sep 30 20:39:12 CEST 2015
If your code is new enough that it is written like this:
with open('output.txt', 'w') as f:
f.write('Stuff')
you don't have to worry, you will be fine. The with statement will
handle the closing for you.
If you don't use many files, well things will still work. It's sloppy,
but as long as you don't run out of file descriptors, you code will still
work.
If you use lots of files, and don't close them, and don't rely on
the with statement to close them for you ... you can run out. Bad
things happen.
Laura
More information about the pypy-dev
mailing list