Misleading IOerror when opening a non-existent file for append?

jkn jkn_gg at nicorp.f9.co.uk
Mon Nov 20 16:38:15 CET 2006


Hi all

Python 2.4.2 (#1, Apr 26 2006, 23:35:31)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on
linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> ifile=open("\\no_such_dir\\no_such_file" ,'a')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: invalid mode: a
>>>

but:

>>> ifile=open("\\no_such_dir\\no_such_file" ,'r')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory:
'\\no_such_dir\\no_such_file'
>>>

This 'invalid mode: a' error message seems weird to me. Is this a bug
or am I missimg something?

    Thanks
    Jon N




More information about the Python-list mailing list