No os.copy()? Why not?
D'Arcy Cain
darcy at druid.net
Tue Apr 3 15:46:31 EDT 2012
On 03/28/12 16:12, John Ladasky wrote:
> I'm looking for a Python (2.7) equivalent to the Unix "cp" command.
> Since the equivalents of "rm" and "mkdir" are in the os module, I
> figured I look there. I haven't found anything in the documentation.
> I am also looking through the Python source code in os.py and its
> child, posixfile.py.
cp is not a system command, it's a shell command. Why not just use the
incredibly simple and portable
>>>open("outfile", "w").write(open("infile").read())
put it into a method if you find that too much to type:
def cp(infile, outfile):
open(outfile, "w").write(open(infile).read())
--
D'Arcy J.M. Cain <darcy at druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
IM: darcy at Vex.Net
More information about the Python-list
mailing list