Skip to content

Instantly share code, notes, and snippets.

@dyigitpolat
Created September 13, 2022 18:52
Show Gist options
  • Save dyigitpolat/276d02cab6eb31ac57db5e6148e603f0 to your computer and use it in GitHub Desktop.
Save dyigitpolat/276d02cab6eb31ac57db5e6148e603f0 to your computer and use it in GitHub Desktop.
create directories for a file path, if they do not exist. so we can write files in that path.
import os
def prepare_containing_directory(filename):
os.makedirs(filename[:-filename[::-1].find('/')-1], exist_ok=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment