[EMAIL PROTECTED] wrote:
> I'm running code via the "exec in context" statement within a much
> larger program. What I would like to do is capture any possible
> errors and show a pretty traceback just like the Python interactive
> interpreter does, but only show the part of the traceback relating to
> the code sent to exec.
>
> For example here is the code I'm using:
>
> try:
> exec code
> except Exception,Err:
> traceback.print_exc()
Guess what's argument limit is for. Excerpt from the Python docs:
-------------------------------- snip --------------------------------
print_exc( [limit[, file]])
This is a shorthand for print_exception(sys.exc_type, sys.exc_value,
sys.exc_traceback, limit, file). (In fact, it uses sys.exc_info() to
retrieve the same information in a thread-safe way instead of using the
deprecated variables.)
-------------------------------- snip --------------------------------
Ciao, Michael.
--
http://mail.python.org/mailman/listinfo/python-list