[Tutor] Re: Tutor digest, Vol 1 #1268 - 7 msgs
Thu, 13 Dec 2001 12:57:40 -0500
>From: Kirk Bailey <email@example.com>
>Subject: [Tutor] Amazing
>there is nothing I can find for a function or process or ANYTHING to
>determine if a file exists in a specified place. Something like
>exist(filename) really could be useful, but I cannot find any such!
I prefer to use the os.access() function. It gives you more information
than os.path.exists() because it will tell you if it exists AND has certain
file permissions. You just give it the filename and a permissions flag.
The valid permission flags are:
F_OK: existance flag
R_OK: readability flag
W_OK: writability flag
X_OK: executable flag
This tells me that the file exists AND I have the permission to read it.
Likewise, this tells me that it exists and I can write to the file:
Hope this helps,