469,936 Members | 2,420 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,936 developers. It's quick & easy.

Fine-grained OSError subclasses or cross-platform errnos?

Today, I wanted to do something like this:

def nr_files(dirName)
return len(os.listdir(dirName))
except OSError, e:
if e.errno == errno.ENOENT:
return 0

In other words, I wanted to trap only the case of missing directory
(and not, for example, insufficient permissions), and I wanted to do
it in the EAFP style.

The problem is that errno is not cross-platform. Neither is there any
subclass of OSError that I can conveniently catch to figure out what
went wrong.

Is there any better way of doing this?

If not, why not?
Jul 18 '05 #1
0 986

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Rick Hawkes | last post: by
3 posts views Thread by Larry R Harrison Jr | last post: by
6 posts views Thread by shror | last post: by
reply views Thread by service0073 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.