Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'raised': 0.07; 'subclass': 0.09; 'subject:files': 0.09; '>>>': 0.12; 'am,': 0.14; 'wrote:': 0.14; '"on': 0.16; 'dst': 0.16; 'exists:': 0.16; 'oserror': 0.16; 'subject:copy': 0.16; 'windowserror': 0.16; 'traceback': 0.16; '(most': 0.16; 'header:In-Reply-To:1': 0.21; '(this': 0.22; 'last):': 0.23; 'received:209.85.210.174': 0.23; 'received:mail- iy0-f174.google.com': 0.23; 'code': 0.24; "i'm": 0.27; 'subject:?': 0.29; 'exists': 0.29; 'subject:How': 0.30; 'exists,': 0.30; 'it.': 0.31; "skip:' 10": 0.32; 'to:addr:python-list': 0.33; 'error': 0.33; 'file': 0.34; 'header:User-Agent:1': 0.35; '"",': 0.35; 'message-id:@gmail.com': 0.36; 'skip:o 20': 0.37; 'similar': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.37; 'pretty': 0.37; 'subject:from': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'received:192.168.1': 0.40; 'delete': 0.40; 'john': 0.62; 'subject:one': 0.77; 'subject:you': 0.80; '12:06': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=gYv6EFdojA2fwlhwr7ovv2X8sZ1GaWMVNC+q2f4Eo/k=; b=UVESVW1xWJYeGfJRd1uZ/ZzHeZ55/XnKvIyJnVJsFLSJr7OR4ZI2AazozxXwPGJuj9 c6keRPrNGVdEGsUtMIAdde+vkQRkZ5N76J9tW83pw4nvtXBWkRfLJ26g2vYE38aCr81k fzkxMaRoKhTUDEMiXt/isYntMWXOWKRxIJi9w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=RV+xTiHfY+me4ecllSlhej7G+Nndhf3SP8l8RtKy6i6DFVcSuQMPmwdyJ7A2zpQr+4 9DZ2nd0lg0m8FV8rsaVs6wQn9wNKmg8kuVaqVOj0bgP01FzAUqRqtLGpFi0orOi3xTpS j+BYiqRGbLP/o3kyIHSgkNHz18J44WRllZYjk= Date: Fri, 17 Jun 2011 01:15:58 -0500 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5 MIME-Version: 1.0 To: "comp.lang.python" Subject: Re: How do you copy files from one location to another? References: <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> In-Reply-To: <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 16 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308291364 news.xs4all.nl 49046 [::ffff:82.94.164.166]:54306 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7804 On 2011.06.17 12:06 AM, John Salerno wrote: > "On Windows, if dst already exists, OSError will be raised even if it > is a file.." If you try to create a file or directory that already exists on Windows, you'll get a WindowsError with error code 183: >>> os.mkdir('C:\\common\\games') Traceback (most recent call last): File "", line 1, in WindowsError: [Error 183] Cannot create a file when that file already exists: 'C:\\common\\games' I'm pretty sure you have to delete the existing file before you can "overwrite" it. You can try to write the file and delete the file and try again in an except OSError block (this will catch WindowsError as well since it's a subclass of OSError, and it will catch similar errors on other platforms).