[Tutor] os.path.exists(path) returns false when the path actually exists!

Adam A. Zajac strider1551 at gmail.com
Sat Jul 28 04:35:41 CEST 2007


> os.path.exists(path) returns false when the path actually exists!
>  
>  When I do this:
>  
>  >>> os.path.exists("c:\\winnt\\file_name")
>  
>   I get this:
>  >>> False
>  
>  Actually the file exists in c:\winnt, and I can confirm it exists
> there, but os.path.exists isn't returning True, when it should be.. 
>  Is this a bug ?

From the library documentation:
Return True if path refers to an existing path. Returns False for
broken symbolic links. On some platforms, this function may return
False if permission is not granted to execute os.stat() on the
requested file, even if the path physically exists.

So the better question is, does is this file a broken symbolic link or
can os.stat() be executed on it?


More information about the Tutor mailing list