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

Tiger12506 keridee at jayco.net
Tue Jul 31 03:15:18 CEST 2007


> Just to check, try to do away with the backslashes. Windows will accept
> a path with forward slashes just as well:
>
> os.path.exists("c:/winnt/file_name")
>
> Nope, even, with the use of forward slashes in the path, it still returns 
> false
>
> What am I doing wrong here ?
>
> This is driving me nuts!

Not trying to insult you, but you do realize that Windows sometimes hides 
file extensions right? I would assume you know that if you are in this deep, 
but it's better to rule out all the possibilities before doing something 
drastic like taking an axe to your computer. ;-)

For example.
mine.txt

os.path.exists("c:/winnt/mine")
False
os.path.exists("c:/winnt/mine.txt")
True

JS 



More information about the Tutor mailing list