Phoe6 wrote: > Operating System: Windows > Python version: 2.4 > > I have bookmarks.html and wumpus.c under my c: > > When I tried to check the presence of the bookmarks.html, I fail. > >>>> os.path.isfile('c:\bookmarks.html') > False >>>> os.path.isfile('c:\wumpus.c') > True > >>>> os.path.exists('c:\wumpus.c') > True >>>> os.path.exists('c:\bookmarks.html') > False > >>>> os.access('c:\bookmarks.html',os.F_OK) > False > > I can assure you that c:\bookmarks.html exists! and I opened this and > checked it in the browser as well. > > Why is this behavior? And How Should I check for the presence of this > file? > > Any help appreciated. > > Thanks! > Senthil >
Have you tried escaping the "\"? try >>> os.path.exists('c:\\bookmarks.html') '\w' is not a special sequence and therefore gets automagically translated to the escaped "\\w", but "\b" is equivalent to "\x08" and your functions therefore see the string "c;\x08ookmarks.html". If you don't want to escape your strings, use rawstrings (prepend your strings with "r", "c:\bookmarks.html" therefore becomes r"c:\bookmarks.html") -- http://mail.python.org/mailman/listinfo/python-list