I try to open a file for writing using the following:
fh = open("testfile", "w")
But, I get an exception:
IOError: [Errno 17] File exists!
I have write permissions and there is no race condition. Does anyone know why I get the error?
Thanks.
I try to open a file for writing using the following:
fh = open("testfile", "w")
But, I get an exception:
IOError: [Errno 17] File exists!
I have write permissions and there is no race condition. Does anyone know why I get the error?
Thanks.
The wx
mode is something new in Python 3.3, and is documented to raise an error if the file already exists. If w+
mode is working, it seems to me that the code published in the question is not really in line with the error returned...