Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7804
| Date | 2011-06-17 01:15 -0500 |
|---|---|
| From | Andrew Berg <bahamutzero8825@gmail.com> |
| Subject | Re: How do you copy files from one location to another? |
| References | <94a80c85-7a66-4de5-ae35-d4a4b0ea7e37@v8g2000yqb.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.62.1308291364.1164.python-list@python.org> (permalink) |
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 "<stdin>", line 1, in <module>
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).
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do you copy files from one location to another? John Salerno <johnjsal@gmail.com> - 2011-06-16 22:06 -0700
Re: How do you copy files from one location to another? Andrew Berg <bahamutzero8825@gmail.com> - 2011-06-17 01:15 -0500
Re: How do you copy files from one location to another? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-17 19:25 +1200
Re: How do you copy files from one location to another? John Salerno <johnjsal@gmail.com> - 2011-06-17 09:17 -0700
Re: How do you copy files from one location to another? Terry Reedy <tjreedy@udel.edu> - 2011-06-17 15:23 -0400
Re: How do you copy files from one location to another? John Salerno <johnjsal@gmail.com> - 2011-06-17 14:27 -0700
Re: How do you copy files from one location to another? Ethan Furman <ethan@stoneleaf.us> - 2011-06-17 15:15 -0700
Re: How do you copy files from one location to another? John Salerno <johnjsal@gmail.com> - 2011-06-17 16:28 -0700
Re: How do you copy files from one location to another? Tim Golden <mail@timgolden.me.uk> - 2011-06-17 09:04 +0100
Re: How do you copy files from one location to another? Heather Brown <heather@dejaviewphoto.com> - 2011-06-17 12:43 -0400
Re: How do you copy files from one location to another? Michael Hrivnak <mhrivnak@hrivnak.org> - 2011-06-18 13:13 -0400
Re: How do you copy files from one location to another? Terry Reedy <tjreedy@udel.edu> - 2011-06-18 16:52 -0400
csiph-web