Created
February 6, 2020 17:17
-
-
Save JoaoCarabetta/21bd5c4394c274e514c412529af865e5 to your computer and use it in GitHub Desktop.
Safely create a path in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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