[EMAIL PROTECTED] wrote: > I wanted to write the following code: > > import shelve > try: > db = shelve.open(file, "r") > except SomeError: > print "Oh no, db not found" > > Only, I'm not sure what SomeError should be. I tried error, > anydbm.error, shelve.open.anydb.error, etc. but can't find it. Things > worked fine with simply except:, but that's not optimal. > > Does anyone know either the what the error is or where I can find it > for certain? > > Thanks, > Martin
What error did you get with just the bare except? you can find out by saying (for instance): >>> try: 1/0 except Exception, err: E = err >>> E <exceptions.ZeroDivisionError instance at 0xb6efd8cc> or to get really fancy, use the traceback module >>> from traceback import format_exc >>> try: 1/0 except: print format_exc() Traceback (most recent call last): File "<pyshell#10>", line 2, in ? ZeroDivisionError: integer division or modulo by zero Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list