Basic file operation questions
Grant Edwards
grante at visi.com
Tue Feb 8 16:39:22 EST 2005
On 2005-02-08, Marc Huffnagle <mhuffnagle at knowtechnology.net> wrote:
>>>for line in file(...):
>>> # do stuff
> When you read a file with that method, is there an implied close() call
> on the file? I assume there is, but how is that handled?
The file will be closed when the the file object is deleted by
the garbage collection algorithm. That will happen sometime
after the for loop exits and before the program exits. In
normal C-Python I believe it happens immediately after the for
loop exits. However, that behavior is not guaranteed by the
language spec.
--
Grant Edwards grante Yow! Now that I have my
at "APPLE", I comprehend COST
visi.com ACCOUNTING!!
More information about the Python-list
mailing list