checking for when a file or folder exists, typing problems?

Scott David Daniels Scott.Daniels at Acm.Org
Sun Jun 12 12:17:56 EDT 2005


Bryan Rasmussen wrote:
> ... at one point in my program I check if a file exists using
>     if exists("c:\projects"):

You should not be using a backslash in non-raw-string source to
mean anything but "escape the next character."  The above should
either be written as:
     if exists(r"c:\projects"):
or:
     if exists("c:\\projects"):

I suspect you problem has to do with this difference, but perhaps not.
Give exact short code that actually demonstrates the problem.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list