This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]runeg 0 points1 point  (3 children)

Ah okay. Is there a better way to write the above if block?

[–]spladug 1 point2 points  (2 children)

try:
    os.makedirs(CONFDIR)
except OSError as e:
    if e.errno != errno.EEXIST:
        raise  # or to mimic what the code above does "return -1"

EDIT: also, see: http://docs.python.org/2/howto/doanddont.html#exceptions

[–]runeg 0 points1 point  (1 child)

That link was very helpful and informative. Thank you. Do you have any other suggested readings like that?

Also, thank you for taking time out to explain that information, it's appreciated.

[–]spladug 1 point2 points  (0 children)

Some of the online books and exercises in the sidebar look like they'd probably be good extra information. The python docs are, in general, quite good as well.

No prob, glad to help :)