shutil rant

Gerson Kurz moc.q-dnan-p at p-nand-q.com
Fri May 17 08:04:09 EDT 2002


So, I want to make *exact* copies of files. The first function I find
is in shutil

"""copyfile(src, dst) 
Copy the contents of the file named src to a file named dst. If dst
exists, it will be replaced, otherwise it will be created...."""

I use that function, only to find out what the documentation will not
tell you, that neither the file attributes nor the file date is
copied. :(

So, I'm reading the whole doc page on "shutil". It has the two
ingeniously named functions

"""copy(src, dst) 
Copy the file src to the file or directory dst...Permission bits are
copied..."""

and

"""copy2(src, dst) 
Similar to copy(), but last access time and last modification time are
copied as well."""

I try copy2, gruntling about the great name choice, but find that the
hidden attribute is not copied (on Windows 2000 using ActivePython
2.2.1 Build 222). The "Read Only" bit is copied. I look into the
source of lib\shutil.py and find that copy2 is a wrapper for copystat,
which means it won't work neither; basically it uses the stuff from
the "stat" module which doesn't have support for anything other than
the unix file-permission bits. 

Now I know about general unix superiority and all that, but ... do I
really have to resort to "import win32api" in order to make an exact
file copy on windows? 







More information about the Python-list mailing list