file closing

laotseu bdesth at removethis.free.fr
Thu May 22 06:45:23 EDT 2003


Colin Brown wrote:
> After reading replies to a previous thread about potential loss of data
> when not closing a file after writing it, I got to wonder if the following
> two codes snippets are functionally the same after all:
> 
> f = file('test.dat','w')
> f.write(chr(0)*1000000)
> f.close()
> 
> file('test.dat','w').write(chr(0)*1000000)
> 
> Does the first case explicitly close the file
Yes, seems clear ! re-read the third line !-)

> where the second one relies on
> garbage collection?
Yes, AFAIK.

Laotseu





More information about the Python-list mailing list