Most efficient way to write data out to a text file?
Christos TZOTZIOY Georgiou
DLNXPEGFQVEB at spammotel.com
Thu Jun 27 08:16:46 EDT 2002
On 27 Jun 2002 02:01:35 GMT, rumours say that bokr at oz.net (Bengt
Richter) might have written:
>Try accumulating your chunks in a list,
>like sl=[] followed by sl.append('chunk') instead, and then do f.write(''.join(sl))
>instead of the f.write(s) you would have done.
A minor correction, if I may add:
f.writelines(sl)
might be quite more efficient than
f.write(''.join(sl))
AFAIK the output is the same, as long as one remembers to insert the
necessary '\n' for line breaks where needed :)
--
TZOTZIOY, I speak England very best,
Real email address: 'dHpvdEBzaWwtdGVjLmdy\n'.decode('base64')
More information about the Python-list
mailing list