Path: csiph.com!usenet.pasdenom.info!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'memory.': 0.05; 'module,': 0.05; 'shutil': 0.07; 'python': 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; 'subject:Why': 0.16; 'shell': 0.18; 'wrote:': 0.19; 'option.': 0.21; 'header:In-Reply-To:1': 0.22; 'skip:" 30': 0.23; "haven't": 0.24; 'cc:2**1': 0.26; 'unix': 0.26; 'header:User-Agent:1': 0.26; 'said,': 0.27; 'skip:> 10': 0.27; 'cc:addr:python.org': 0.28; 'there.': 0.28; 'source': 0.29; 'received:209.85.210.174': 0.30; 'received:mail-iy0-f174.google.com': 0.30; 'received:209.85': 0.32; 'received:google.com': 0.32; 'code': 0.32; 'file': 0.33; 'received:209.85.210': 0.33; 'received:209': 0.35; 'subject:?': 0.35; 'why': 0.37; 'subject:: ': 0.37; 'charset:us-ascii': 0.38; 'anything': 0.38; 'header:Received:5': 0.40; 'most': 0.61; '2012': 0.62; 'john': 0.64; 'content-disposition:inline': 0.65; 'idiomatic': 0.84; 'incredibly': 0.96 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=oqQJ4HHWtC2R1BQ78h+wim9hyrfcNBXLb+X+YYP5+kc=; b=OvaCbu/6Nh5AoQ9eLbBxo3EqinZPYqihA/zryNdYFEBHCNivewMcR+VgffRtbodt4y ILxW24bfKkLznbkoA3V2welk6ih7PZv/aC8VloRV7WefxPe6xrQHoJvoFPme/8UvAZKT fT1PK33lsjECTAipCbzr9bN4TE5DNlMZtHQdCFQONsDn01ZHLbLZMTiTebcqejOVh1hW kSA8mFR5lJrMaqWcDmkN3mTtQiRyKGLoiI2w33tfOi50jE+slKM99PzjdE5Dwjg2iJlq t6oNxUuB7VrdDSNJZmNjYKfOLCFizGfHvzQYjbzGIh6cNjHbbTHAJS5+GPGqcm/hU0oZ hSuw== Date: Tue, 3 Apr 2012 15:10:32 -0500 From: Tycho Andersen To: D'Arcy Cain Subject: Re: No os.copy()? Why not? References: <38b3fc48-1d05-4373-b32e-64da95173864@pz2g2000pbc.googlegroups.com> <4F7B5397.8070405@druid.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F7B5397.8070405@druid.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQl0rKc2+sb0QzsAd8fNS0bS7jTaiu42n9a0hyJTus2I+QyYauU/zqk2FD6pyarXWLva/SFy Cc: python-list@python.org, john_ladasky@sbcglobal.net 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1333483818 news.xs4all.nl 6929 [2001:888:2000:d::a6]:42858 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22630 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