[Tutor] error in writelines
LL
Lbrannma at yahoo.com
Sun Sep 10 06:51:59 CEST 2006
Hi All,
I have a list containing 108 filenames. I want to open each file and write it to an output file, appending it to the previous write. I use the code below. Everything appears to work fine until I reach file 107. Only part of the file is written, and file 108 is not written at all. The program runs to completion (I get exit code 0). I debugged the problem and found that readlines() is reading all of file 107's contents but that writelines() is not writing all of file 107's contents. There are no strange characters where the write stops.
Any advice would be greatly appreciated.
Thanks,
Lance
-----------------------------------------------------------------
fileobjectw = open(COMPILETRACEDIR + '\\IncludeCode.prg', 'w')
for line in listext:
line = string.strip(line)
fileobjectr = open(line, 'r')
sa = fileobjectr.readlines()
fileobjectr.close()
fileobjectw.writelines(sa)
fileobjectw.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060910/9f0faca2/attachment.html
More information about the Tutor
mailing list