[Python-Dev] mkdir -p in python (original) (raw)
Ben Finney ben+python at benfinney.id.au
Thu Jul 22 07:52:45 CEST 2010
- Previous message: [Python-Dev] mkdir -p in python
- Next message: [Python-Dev] mkdir -p in python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Ewing <greg.ewing at canterbury.ac.nz> writes:
Ray Allen wrote:
> I think in this case, the errno is generate by c standard library, > which can be seen as cross-platform. But I'm never sure how standard the actual error numbers are, though.
You can use them by name, and in fact I strongly recommend it:
import os
import errno
try:
os.makedirs(path)
except OSError, exc:
if exc.errno != errno.EEXIST:
raise
I tend to think of them as coming from Unix-land, and thus fair game for getting screwed around with on Windows. Am I worrying too much?
There are some that differ between different OSen, true. Using them by name avoids dealing with different numbers (since the ‘errno’ module's attributes will use the same name for semantically the same error), leaving only the problem of errors that are missing on some platforms. EEXIST is common to all of them though, AFAIK.
-- \ “Sittin' on the fence, that's a dangerous course / You can even | `\ catch a bullet from the peace-keeping force” —Dire Straits, | o_) Once Upon A Time In The West | Ben Finney
- Previous message: [Python-Dev] mkdir -p in python
- Next message: [Python-Dev] mkdir -p in python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]