"Cloning" file attributes and permissions

attn.steven.kuo at gmail.com attn.steven.kuo at gmail.com
Thu Apr 12 20:25:10 EDT 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:
>

(snipped)

>
>
> 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?

--
Regards,
Steven










More information about the Python-list mailing list