Skip to content

Instantly share code, notes, and snippets.

@JoaoCarabetta
Created February 6, 2020 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoaoCarabetta/21bd5c4394c274e514c412529af865e5 to your computer and use it in GitHub Desktop.
Save JoaoCarabetta/21bd5c4394c274e514c412529af865e5 to your computer and use it in GitHub Desktop.
Safely create a path in python
def safe_create_path(path, replace=False):
try:
if replace:
if os.path.isfile(path):
shutil.rmtree(path)
os.makedirs(path)
except Exception as e:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment