Copy files in cross-platform manner

Sean 'Shaleh' Perry shalehperry at attbi.com
Fri Aug 23 23:20:34 CEST 2002


On Friday 23 August 2002 11:03 am, Greg Fortune wrote:
> 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()
>
>

import shutil
shutil.copy()

I believe it is portable.




More information about the Python-list mailing list