file copy portability

Bob Smith bob_smith_17280 at hotmail.com
Tue Jan 18 20:18:39 EST 2005


John Machin wrote:
> Bob Smith wrote:
> 
>>Is shutil.copyfile(src,dst) the *most* portable way to copy files
> 
> with
> 
>>Python? I'm dealing with plain text files on Windows, Linux and Mac
> 
> OSX.
> 
>>Thanks!
> 
> 
> Portable what? Way of copying??
> 
> Do you want your files transferred (a) so that they look like native
> text files on the destination system, or (b) so that they are exact
> byte-wise copies?
> 
> A 5-second squint at the source (Lib/shutil.py) indicates that it
> provides, reliably and portably, option b:
> fsrc = open(src, 'rb')
> fdst = open(dst, 'wb')
> 
> One way of doing option (a): you would need to be running Python on the
> destination system, open the src file with 'rU', open the dst file with
> 'w'.
> 

The files are not copied from one platform to the other. The app must 
run on all platforms. I want to make the app as portable as possible to 
reduce platform specific code.



More information about the Python-list mailing list