No os.copy()? Why not?

Roy Smith roy at panix.com
Wed Apr 4 08:08:31 EDT 2012


On Tue, 03 Apr 2012 15:46:31 -0400, D'Arcy Cain wrote:
> > cp is not a system command, it's a shell command.  Why not just use the
> > incredibly simple and portable
> > 
> >    >>>open("outfile", "w").write(open("infile").read())

In article <4f7be1e8$0$29999$c3e8da3$5496439d at news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> Because your cp doesn't copy the FILE, it copies the file's CONTENTS, 
> which are not the same thing.

Not to mention that this will read the entire contents of the file into 
memory at once.  Probably don't want to do that with 100 GB of data.

Slightly off-topic, but are there file systems these days which support 
off-line copying?  If I have a disk at the other end of a network link, 
it would be nice to tell the disk to copy a file and tell me when it's 
done.  As opposed to dragging all that data over the network just so I 
can buffer it in local memory and shove it right back out the network 
port to the same disk.  That kind of stuff used to be standard practice 
in the neanderthalic days of IBM mainframes.



More information about the Python-list mailing list