Fredrik Lundh wrote:
  > assuming that "true" means "the message you would get if you hadn't
 > used a try/except", the traceback module is what you want:
 >
 > you can also inspect the exception status via the sys.exc_info() call.
 > e.g.
 >
There is also the third way of catching an exception explicitly and 
printing it's arguments and class (doesn't give exactly the same 
information, but gives relevant informations nonetheless)

--
 >>> try:
        1/0
except ZeroDivisionError, e:
        print e
        print e.args
        print repr(e)

        
integer division or modulo by zero
('integer division or modulo by zero',)
<exceptions.ZeroDivisionError instance at 0x00E35850>
--

(catching Exception instead of ZeroDivisionError would yield the same 
result, but would also act as an Exception trap that voids any exception 
raised)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to