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:
import os if os.path.isfile(filename): print "file exists" else: "Your code here"
Where your code here is use the (touch) command
This will check if the file is there if it is not then it will create it.