I tried what you said and it looked like maybe AttributeError, but that didn't work either.
This code snippet: import shelve from traceback import format_exc try: db = shelve.open("meh", "r") except: print format_exc() Gave me this output: Traceback (most recent call last): File "test.py", line 5, in ? db = shelve.open("meh", "r") File "/usr/lib/python2.4/shelve.py", line 231, in open return DbfilenameShelf(filename, flag, protocol, writeback, binary) File "/usr/lib/python2.4/shelve.py", line 212, in __init__ Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback, binary) File "/usr/lib/python2.4/anydbm.py", line 77, in open raise error, "need 'c' or 'n' flag to open new db" error: need 'c' or 'n' flag to open new db Exception exceptions.AttributeError: "DbfilenameShelf instance has no attribute 'writeback'" in ignored Do you know what the error is? Thanks, Martin Simon Forman wrote: > [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