def mkdir(newdir):
if os.path.isdir(newdir):<EOL><INDENT>pass<EOL><DEDENT>elif os.path.isfile(newdir):<EOL><INDENT>raise OSError("<STR_LIT>""<STR_LIT>" % newdir)<EOL><DEDENT>else:<EOL><INDENT>head, tail = os.path.split(newdir)<EOL>if head and not os.path.isdir(head):<EOL><INDENT>mkdir(head)<EOL><DEDENT>if tail:<EOL><INDENT>os.mkdir(newdir)<EOL><DEDENT><DEDENT>
works the way a good mkdir should :)
    - already exists, silently complete
    - regular file in the way, raise an exception
    - parent directory(ies) does not exist, make them as well