On Tue, Apr 03, 2012 at 03:46:31PM -0400, D'Arcy Cain wrote:
> 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())

Note, though, that this reads the whole file into memory. As many
others have said, shutil is the most idiomatic option.

\t
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to