Last active
April 11, 2019 07:09
-
-
Save void32/75f0301b0ed8306f235760055e332a0a to your computer and use it in GitHub Desktop.
mkdir -p' in Python
This file contains 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 mkdir_p(path): | |
""" 'mkdir -p' in Python """ | |
try: | |
os.makedirs(path) | |
except OSError as exc: # Python >2.5 | |
if exc.errno == errno.EEXIST and os.path.isdir(path): | |
pass | |
else: | |
raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment