I have spent 4hrs+ trying to figure out why I can't catch an IOError. Most of the solutions I find, seem to be python-2 specific. I'm using python-3. Take a look at this:
def getfile(cfg): try: with open(cfg, 'r', encoding='utf-8') as tmp_file: tmp = tmp_file.read().strip().split('\') except IOError as err: print ('Finally, I caught one', err)
That's just about it. I have had different versions of it without success.