accessing detail about Exceptions
Steve Purcell
stephen_purcell at yahoo.com
Tue Apr 24 02:31:41 EDT 2001
Bill Seitz wrote:
> I'm pretty new to Python, but my books are pre-v2. Is there any good example
> code anywhere for catching exceptions? I'm particularly interested in
> accessing the "associated value" info, without having trapped a particular
> type of exception (in other words, I want to catch with a generic "except:"
> if possible, not "except ValueError:"...)
Look at 'exc_info()' in the 'sys' module:
try:
something_or_other()
except:
exc_type, exc_value, traceback = sys.exc_info()
The exception value you want is 'exc_value' in this case.
-Steve
--
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo
More information about the Python-list
mailing list