Created
January 28, 2013 09:40
-
-
Save zertrin/4654267 to your computer and use it in GitHub Desktop.
Make sure path exists, trying to create the path and raising exception in case of problem (except when it's just because the path already exist)
From http://stackoverflow.com/questions/273192/python-best-way-to-create-directory-if-it-doesnt-exist-for-file-write/5032238#5032238
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
import os | |
import errno | |
def make_sure_path_exists(path): | |
try: | |
os.makedirs(path) | |
except OSError as exception: | |
if exception.errno != errno.EEXIST: | |
raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment