Need function to test if EFFECTIVE UID has read-access to a file.

Peter Hansen peter at engcorp.com
Thu Nov 18 12:13:37 EST 2004


Markus Kemp wrote:
> Oh, and another reason why I can't use the method suggested by you is
> that I'm dealing with directories, not files. Then again .... I guess
> I could do something like:
> 
> try:
>     os.listdir( strPathname )
> except:
>     print "No read access to pathname", strPathname, "!"
> 
> Problem is, I don't wanna catch __everything__. Does anyone know what
> kind of exception is.listdir() throws if it fails to read a directory?

Why not just set up the conditions you are interested in
and try it yourself?  There are probably various different
ways to "fail to read a directory", so it would be best
if you created the specific conditions you want and tried
it out from the interactive prompt.

-Peter



More information about the Python-list mailing list