Best way to copy files without Read-Only option

Kiss, Arpad AKiss at
Tue Sep 5 16:57:59 CEST 2000

shutil.copy2 copies last access time and last modification time and os.chmod
can set the read-only flag.
The mode parameter of os.chmod is not documented on win32(at least I haven't
find it) so you can examine the os.stat return values and then use these
constants(0x81b6 and 0x8124), or create a file in the destination dir then
use shutil.copymode to copy the mode of this new file.

"Olav" <OlavB at> wrote in message
news:<39B4EF5E.22DE5B90 at>...
> Thanks!
> I should have though about that.  But still - now I can't set the dates
> (I would like that the copied file has the same dates as the original).
> --And also I suspect it is not really efficient.
> Olav
> Rainer Deyke wrote:
> > "Olav Benum" <Olav.Benum at> wrote in message
> > news:39AE7EAE.51E3E692 at
> > > However, I have the problem that when the source is "Read-only" the
> > > file
> > > is also read-only, creating problems later.
> >
> > Open source file and destination file.  Read from source file; write to
> > destination file.  When all data has been copied, close both files.
> >
> > --
> > Rainer Deyke (root at
> > Shareware computer games           - 
> > "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

More information about the Python-list mailing list