[Tutor] do I need f.close()
dave selby
dave6502 at googlemail.com
Wed Jun 11 11:10:54 CEST 2008
Thanks for all your help guys, I am getting a strong consensus that
f.close() should be used everywhere, reading files as well as writing
files and not to rely on the PVM to do clean-up for you.
The whole topic came up because I just finished reading 'learning
python' 3rd edition OReilly as a refresher where there are multiple
instances of suggesting that you do the exact opposite eg ...
[line.rstrip() for line in open('myfile')] ... p361
for line in open('script1.py') ... p261& p276 where it is described as
'best practice' for reading files line by line
etc ...
Dave
--
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
More information about the Tutor
mailing list