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.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to