Fully handling exceptions.

Jordan Katz katz at underlevel.net
Sat Aug 18 17:01:35 EDT 2001


Hi,

  I have the following piece of code:

    import urllib
    try:
      src_in = urllib.urlopen(ag_url)
    except IOError:
      print '%s : connection cannot be made or \
             server returned error.' %(ag_url)
    except:
      print '%s : unknown error.' %(ag_url)

  urllib's manual documents IOError as the only possible exception
  raised by urlopen; does this make my last except superfluous, or can
  there be other exceptions raised when urlopen is called that the
  last except may handle?

Thanks,
-- 
Jordan Katz <katz at underlevel.net>  |  Mind the gap



More information about the Python-list mailing list