Copy files in cross-platform manner

Greg Fortune lists at gregfortune.com
Fri Aug 23 20:03:56 CEST 2002


Is there any builtin python function that I've overlooked for copying 
files?  rename works great if you just need to move the file, but I 
actually need to make a copy.

The most obvious way to me is

in_file = open(src_file, 'r')
inp = in_file.read()
in_file.close()

out = open(dst_file, 'w')
out.write(inp)
out.close()


but I'd rather make a call to the os module and leave all the IO in C 
code...


Thanks,

Greg



More information about the Python-list mailing list