Skip to content

Instantly share code, notes, and snippets.

@Bas-Man
Last active December 12, 2018 14:08
Show Gist options
  • Save Bas-Man/01377cbf912b89669c6edcb2b1d51795 to your computer and use it in GitHub Desktop.
Save Bas-Man/01377cbf912b89669c6edcb2b1d51795 to your computer and use it in GitHub Desktop.
Python raise OSError for missing file or invalid path
if not os.path.exists(self.path):
raise OSError(
errno.ENOENT, os.strerror(errno.ENOENT), self.path
)
if not os.path.isfile(self.path + self.file):
raise OSError(
errno.ENOENT, os.strerror(errno.ENOENT), self.file
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment