Reputation: 14982
I am officially lost.. I have a trivial piece of python which checks whether a file exists. The path is stored in a dictionary.
When I execute next line of code, it returns false:
if not os.path.exists(self.parameters['icm_profile']):
raise FileDoesNotExistError(PreprocessingErrors.FileNotPresent, "icm profile {} not found".format(self.parameters['icm_profile']))
When I copy THE EXACT STRING and execute the next line, it returns true:
if not os.path.exists("S:\\IAI\\Data\\Recipes\\BGD\\Inkjet\\LPI\\CMY_360x720dpi_2dpd_profilev6.icm"):
print("aap")
Thus, then the path does exist.
There is no difference I can think of... What in gods name am I doing wrong?
Upvotes: 0
Views: 1620
Reputation: 2939
Looks to me like you've got an extra pair of quotes in there which could be causing you hassle. Try:
self.parameters['icm_profile'][1:-1]
Another approach mentioned by DeepSpace is to use
self.parameters['icm_profile'].strip('"')
Or if you're really paranoid
self.parameters['icm_profile'].strip('"').strip("'")
Upvotes: 1