+1 on the general idea, always seemed awkward to me that these operations all raise the same exception. I didn't even know about the errno comparison method, though I've never looked for it. Point is that it is cryptic and as such not very pythonic.