check whether directory is readable
bignose+hates-spam at benfinney.id.au
Tue Aug 23 13:38:35 CEST 2005
eels <eels at nikocity.de> wrote:
> how can I check whether a directory is readable or not. Are there
> differences between unix and windows?
The Pythonic way would be to just do what you need to do (in this
case, presumably, read the directory) and catch the specific exception
(in this case, presumably, OSError).
# Do whatever needs a readable directory
except OSError, e:
# Do whatever we need to when the directory is unreadable
print "Unable to read stuff:", e.strerror
\ "I got contacts, but I only need them when I read, so I got |
`\ flip-ups." -- Steven Wright |
More information about the Python-list