Get Only the Last Items in a Traceback
Michael Ströder
michael at stroeder.com
Wed Sep 12 05:21:48 EDT 2007
More information about the Python-list mailing list
Wed Sep 12 05:21:48 EDT 2007
- Previous message (by thread): Get Only the Last Items in a Traceback
- Next message (by thread): Get Only the Last Items in a Traceback
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
gregpinero at gmail.com 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.
- Previous message (by thread): Get Only the Last Items in a Traceback
- Next message (by thread): Get Only the Last Items in a Traceback
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list