Skip to content

Instantly share code, notes, and snippets.

@zertrin
Created January 28, 2013 09:40
Show Gist options
  • Save zertrin/4654267 to your computer and use it in GitHub Desktop.
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
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