A silly question on file opening

Anthony Tolle anthony.tolle at gmail.com
Wed Feb 10 21:57:52 CET 2010

On Feb 10, 3:42 pm, joy99 <subhakolkata1... at gmail.com> wrote:
> Dear Group,
> [snip]
> I tried to change the location to D:\file and as I saw in Python Docs
> the file reading option is now "r+" so I changed the statement to
>    file_open=open("D:\file","r+")
> but it is still giving error.

Only use "r+" if you need to also write to the file.  "r" is still
good for opening for reading.

Without seeing a traceback, I can only assume the error is caused by
using a backslash in the path without escaping it.  Try either the



For an explanation, see the Python documentation:


More information about the Python-list mailing list