denis.spir at free.fr
Sat Jun 13 17:05:47 CEST 2009
Le Sat, 13 Jun 2009 10:25:19 +0200,
spir <denis.spir at free.fr> s'exprima ainsi:
> this post is half a question, half a proposal.
> Q: what happens to the filesystem file, and to the python file object below?
> text = file(fn).read()
> (used 'file' instead of 'open' in purpose)
> Note that there seemingly is no way to close or del the file object, nor
> even to check its 'closed' flag. I would expect that, in the case a file
> remains unnnamed, it is automatically closed and del-ed. If not, do you
> think it is sensible to ensure that?
Actually, I could have answered my own question, at least for the current CPython implementation:
<open file 'test.txt', mode 'r' at 0xb7dbbbf0>
Seems to shows the file has been closed.
la vita e estrany
More information about the Python-ideas