On 07/10/11 18:56, lina wrote:
On Oct 8, 2011, at 0:39, "Prasad, Ramit"<ramit.pra...@jpmorgan.com> wrote:
I would really change this to explicitly close the file.
with open(base+OUTFILEEXT,"w") as f:
f.write(str(summary))
Btw, I do notice lots of suggestions of closing file.
Does your above sentence close the file here? Implicitly ?
Sorry, I don't see "close"
The 'with' syntax above implicitly closes the file for you
at the end of the block. If you use the
f = open(...)
style you are expected to explicitly close the file when you are
finished with it. This is especially important when writing to a file
because that will guarantee that the OS writes the data to the file on
disk. Without a close its possible for your data to get held in a
buffer that doesn't get written to disk. Rare, but possible.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor