[Tutor] fileobject.close() question

alan.gauld@bt.com alan.gauld@bt.com
Thu, 13 Apr 2000 17:26:59 +0100

> I forgot it, but at the same time, in the Quick Python book, pg. 132,
> section 13.2, curiously enough, it says:
> 	"In small scripts, not closing a file object will generally
> 	not have much of an effect.."

Because Python will close it for you when it garbage 
collects the objects at the end of the session.

You are running from the interpreter so the object is still 
referenced, if you had exitted Python the file would have 
been written(I assume!!)

Equally if your code was in a script file which you ran 
from the OS prompt then it would have worked as expected.
Personally I'm paranoid and allways close files by hand 

Alan G.