No os.copy()? Why not?

Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Tue Apr 3 02:24:53 EDT 2012


Am 02.04.2012 23:11 schrieb HoneyMonster:

> One way:
> import os
>
> os.system ("cp src sink")

Yes. The worst way you could imagine.

Why not the much much better

from subprocess
subprocess.call(['cp', 'src', 'sink'])

?

Then you can call it with (really) arbitrary file names:


def call_cp(from, to):
     from subprocess
     subprocess.call(['cp', '--', from, to])

Try that with os.system() and from="That's my file"...


Thomas



More information about the Python-list mailing list