Unable to Concatenate a file - destination kept getting overwritten

Chris Angelico rosuav at gmail.com
Fri Apr 20 22:27:43 EDT 2012


On Sat, Apr 21, 2012 at 11:03 AM, Foster Rilindo <rilindo at me.com> wrote:
> Is this right way to concatenate a file or is there a better way?

I'd be inclined to ignore shutil and simply open one file for reading,
the other for appending, and manually transfer data from one to the
other.

open(disk1,"ab").write(open(disk2,"rb").read()) # untested

This one-liner doesn't explicitly close its files, doesn't check for
errors, etc, etc, but it should give you the idea of what's going on.

ChrisA



More information about the Python-list mailing list