urllib2 and exceptions

alex23 wuwei23 at gmail.com
Sun Sep 28 20:33:47 EDT 2008


On Sep 29, 5:52 am, robean <st1... at gmail.com> wrote:
> Actually, the problem seems to be that IOError is in my namespace, but
> the other error classes are not. So,
>
>    except HTTPError, etc.
>
> fails, but
>
>    except urllib2.HttpError, etc.
>
> works fine. Now, I still don't understand why these classes shouldn't
> automatically work....

IOError is a standard Python exception. HTTPError & URLError are
exceptions provided by the urllib2 module. They need to be imported
from or referenced through urllib2 to be used.



More information about the Python-list mailing list