Why does this fail?

Mark McEahern mark at mceahern.com
Mon Jan 5 02:40:23 CET 2004

On Sun, 2004-01-04 at 18:58, Dave Murray wrote:
> New to Python question, why does this fail?

>     try:
>     except:

Because you're treating all errors as if they're what you expect.  You
should be more specific in your except clause.  Do this and you'll see
what I mean:

    raise # raise whatever exception occurred
    return 0

In other words, you should be explicit about the errors you silence.

Also, it's not clear what Checkit() is actually supposed to do.  Is it
supposed to verify the URL actually exists?  urllib doesn't raise an
error for 404 not found--urllib2 does.  Try that instead.


// m

More information about the Python-list mailing list