"Cloning" file attributes and permissions

attn.steven.kuo at gmail.com attn.steven.kuo at gmail.com
Fri Apr 13 02:25:10 CEST 2007

On Apr 12, 5:19 pm, attn.steven.... at gmail.com wrote:
> On Apr 12, 4:09 pm, Paulo da Silva <psdasil... at esotericaX.ptX> wrote:


> import subprocess
> retcode = subprocess.call([ "/bin/cp", "-p", oldfile, newfile ])
> On my system, this preserves the access permissions and ownership.
> And if you modify the file after copying, you can alter
> the access and modification times with posix.utime
> to match that of the original.

After poking around a bit I also discovered the
shutil module.  It looks like you can use
shutil.copy2.  More Pythonic, yes?


More information about the Python-list mailing list