Misleading IOerror when opening a non-existent file for append?
jkn
jkn_gg at nicorp.f9.co.uk
Tue Nov 21 06:50:30 EST 2006
Hi there
Thanks for the comments. I see that I actually confused myself a
bit with my posting. It's been a while and I mistook the use of '/' as
a platform-independent directory delimiter with the use of '\\'.
I also thought that I was seeing something similar on Windows and
Linux. This may not be the case ;-o.
So, to try again. It looks as it the attempt to open a non-existent
file (for instance, because the parent folder does not exist) gives an
odd error on Linux but not on Windows.
On Windows:
> >>> f = file(r'c:\does-not-exist\DoesNotExist.txt','a')
>
> Traceback (most recent call last):
> File "<pyshell#0>", line 1, in <module>
> f = file(r'c:\does-not-exist\DoesNotExist.txt','a')
> IOError: [Errno 2] No such file or directory: 'c:\\does-not-exist
> \\DoesNotExist.txt'
> >>>
(replacing the '\' with '/' gives the same message, which is what I was
trying to convey)
On Linux, you get the 'Bad mode' error.
Strange?!
Jon N
More information about the Python-list
mailing list