A simple way to build the paths in POSIX systems. Assume your path is something like: dirPath = '../foo/bar', where neither foo or bar exist:
path = ''
for d in dirPath.split('/'):
# handle instances of // in string
if not d: continue
path += d + '/'
if not os.path.isdir(path):
os.mkdir(path)