import os, errno def makedirs(path): if not os.path.exists(path): try: os.makedirs(path) except OSError, e: if e.errno != errno.EEXIST: raise