catch UnicodeDecodeError

jaroslav.dobrek at gmail.com jaroslav.dobrek at gmail.com
Thu Jul 26 13:58:03 CEST 2012


> that tells you the exact code line where the error occurred. No need to
> look around.


You are right:

try:
    for line in f:
       do_something()
except UnicodeDecodeError:
    do_something_different()

does exactly what one would expect it to do. 

Thank you very much for pointing this out and sorry for all the posts. This is one of the days when nothing seems to work and when I don't seem to able to read the simplest error message. 




More information about the Python-list mailing list