0

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.

Edited by twohot: n/a

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by twohot
0

you mean:

tmp = tmp_file.read().strip().split('\n')

Thanks for spotting that.
I later found the culprit... (not even represented well in my example here). Had the try-except block on a different hierarchy from the code it was meant to watch.

0

you mean:

tmp = tmp_file.read().strip().split('\n')

Thanks for spotting that.
I later found the culprit... (not even represented well in my example here). Had the try-except block on a different hierarchy from the code it was meant to watch.

....
naaah! On second thoughts, I'll just shift the database section to SQL and use a 'books' as an interface to the database.

Thanks again

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.