exceptions, internals (introspection?)

Fredrik Lundh fredrik at pythonware.com
Thu Nov 10 15:47:12 EST 2005


"ej" <"ej atwellkeepercom"@bag.python.org> wrote

> try:
>    {}['foo']
> except Exception, x:
>    print "class of x =", x.__class__
>    print "type(x) =", type(x)
>    print "dir(x) =", dir(x)
>
>    If you don't handle an exception, the interpreter will quit and print a
> stack trace. What I'm not seeing is how to handle the exception, but still
> get the stack trace as a string so I could dump it to a log file or email it
> or something.

the second example on this page shows you how to do that:

    http://effbot.org/librarybook/traceback

</F> 






More information about the Python-list mailing list