need dict to maintain order

Aahz Maruch aahz at
Sun Jan 20 00:55:29 EST 2002

In article <mailman.1011499888.13384.python-list at>,
Jason Orendorff <jason at> wrote:
>In this *particular* case I think it's unambiguously better.
>If the directory exists, it's foolish to try to create it again;
>if it *doesn't* exist, and you try to create it, and fail
>(permission denied; or device failure), then it's foolish to
>proceed and start putting files in that directory.  Right?

One of the stock arguments in favor of try/except in cases like this is
that your test/create sequence is not an atomic operation.  Therefore
you need to wrap os.mkdir() in a try/except *anyway* (not even talking
about potential problems such as lack of permissions), so why bother
doing the test in the first place?
                      --- Aahz  <*>  (Copyright 2002 by aahz at

Hugs and backrubs -- I break Rule 6       
Androgynous poly kinky vanilla queer het Pythonista   

"I support family values -- Addams family values"

More information about the Python-list mailing list