Copying data between file-like objects

Steven Bethard steven.bethard at gmail.com
Tue Feb 15 11:24:03 EST 2005


Thomas Lotze wrote:
> another question: What's the most efficient way of copying data between
> two file-like objects?
> 
> f1.write(f2.read()) doesn't seem to me as efficient as it might be, as a
> string containing all the contents of f2 will be created and thrown away.

You could try f1.writelines(f2).

Steve



More information about the Python-list mailing list