try:
    os.makedirs(mydir)
except OSError as e:
    if e.errno != errno.EEXIST:
        raise
with open(os.path.join(mydir, filename), 'w') as d:
    d.writelines(list)
Creating a folder with timestamp