[Tutor] Why cannot open a file?

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Tue, 2 Apr 2002 19:04:59 -0800 (PST)


On Wed, 3 Apr 2002, Ares Liu wrote:

> C:\tmp>python
> Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> >>> f = open('foo.foo','W')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> IOError: [Errno 0] Error: 'foo.foo'
> >>> f = open('C:\\tmp\\foo.foo','W')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> IOError: [Errno 0] Error: 'C:\\tmp\\foo.foo'

Hi Ares,

Try lowercase 'w' when you're opening the file in "write" mode.  I believe
that the open() function is case sensitive.  Something like:

    f = open('foo.foo', 'w')


Good luck!