Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'module,': 0.05; 'def': 0.06; 'python': 0.09; '425': 0.09; 'command.': 0.09; 'portable': 0.09; 'cc:addr:python-list': 0.10; 'subject:not': 0.11; 'equivalent': 0.12; 'command,': 0.16; 'equivalents': 0.16; 'im:': 0.16; 'subject:Why': 0.16; 'type:': 0.16; 'shell': 0.18; 'wrote:': 0.19; 'voting': 0.21; 'header:In-Reply-To:1': 0.22; 'skip:" 30': 0.23; "haven't": 0.24; 'cc:2**0': 0.26; 'unix': 0.26; 'header :User-Agent:1': 0.26; 'skip:> 10': 0.27; 'cc:no real name:2**0': 0.27; 'cc:addr:python.org': 0.28; 'there.': 0.28; 'source': 0.29; "i'm": 0.29; 'code': 0.32; 'method': 0.33; 'subject:?': 0.35; 'why': 0.37; 'subject:: ': 0.37; 'anything': 0.38; 'too': 0.39; 'received:net': 0.60; 'john': 0.64; 'child,': 0.84; 'democracy': 0.84; 'received:98.158': 0.84; 'incredibly': 0.96 Date: Tue, 03 Apr 2012 15:46:31 -0400 From: D'Arcy Cain User-Agent: Mozilla/5.0 (X11; NetBSD amd64; rv:11.0) Gecko/20120330 Thunderbird/11.0 MIME-Version: 1.0 To: john_ladasky@sbcglobal.net Subject: Re: No os.copy()? Why not? References: <38b3fc48-1d05-4373-b32e-64da95173864@pz2g2000pbc.googlegroups.com> In-Reply-To: <38b3fc48-1d05-4373-b32e-64da95173864@pz2g2000pbc.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1333482412 news.xs4all.nl 6857 [2001:888:2000:d::a6]:59793 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22627 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 | 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@Vex.Net