I'm trying to raise an error when a directory does not exist, before I open files in that directory. According to this response I should use the most specific Exception constructor for my issue, which I think is NotADirectoryError
. But running the code below I get NameError: global name 'NotADirectoryError' is not defined
. Thanks in advance for any help!
import os
if not os.path.isdir(baselineDir):
raise NotADirectoryError("No results directory for baseline.")
And if there's a better way to do this please suggest it, thanks.