def ensure_dirs_exist(path):
 outdir = os.path.dirname(path)
 if ((outdir != '') and (not os.path.isdir(outdir))):
  os.makedirs(outdir)
 return path

def ensure_dirs_exist ( path ) : outdir = os . path . dirname ( path ) if ( ( outdir != '' ) and ( not os . path . isdir ( outdir ) ) ) : os . makedirs ( outdir ) return path
simple helper that ensures that any directories specified in the path are created prior to use .