What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried:
Under Linux you can create directory in one line:
import os os.system("mkdir -p {0}".format('mydir'))