"Paul Rubin" <http://ph****@NOSPAM.i nvalid> wrote in message
news:7x******** ****@ruckus.bro uhaha.com...
It's messy. Look at sys.exc_info() and go from there.
Yeah, I think I am starting to see what you mean...
#! /usr/local/bin/python
import sys
try:
{}['foo']
except Exception, x:
print "class of x =", x.__class__
print "type(x) =", type(x)
print "dir(x) =", dir(x)
print
(type_, value_, traceback_) = sys.exc_info()
print "type_ =", type_
print "value_ =", value_
print "traceback_ =", traceback_
for key in dir(traceback_) :
print "traceback_ .%s =" % key, eval("traceback _.%s" % key)
print "dir(frame) = ", dir(traceback_. tb_frame)
ej@sand:~/src/python/exceptions> foo
class of x = exceptions.KeyE rror
type(x) = <type 'instance'>
dir(x) = ['__doc__', '__getitem__', '__init__', '__module__', '__str__',
'args']
type_ = exceptions.KeyE rror
value_ = 'foo'
traceback_ = <traceback object at 0x402e2e14>
traceback_.tb_f rame = <frame object at 0x8177b3c>
traceback_.tb_l asti = 18
traceback_.tb_l ineno = 6
traceback_.tb_n ext = None
dir(frame) = ['__class__', '__delattr__', '__doc__', '__getattribute __',
'__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__' ,
'__repr__', '__setattr__', '__str__', 'f_back', 'f_builtins', 'f_code',
'f_exc_tracebac k', 'f_exc_type', 'f_exc_value', 'f_globals', 'f_lasti',
'f_lineno', 'f_locals', 'f_restricted', 'f_trace']
But at least that is something to go on. Thanks for your reply!
-ej