Q: Catching any exception an printing it

Gerrit Holl gerrit.holl at pobox.com
Mon Feb 21 15:42:36 EST 2000


<quote name="Stuart Reynolds" date="951154053">
> Python allows you to do,
> 
> try:
>   if a:
>      raise SomeException()
>   else:
>      raise xyz()
> 
> except:
>   print 'There was an error'
> 
> but is it possible to print out the exception if you don't know what
> type it is? I'd like the above error message to be more useful, but the
> exception raised inside the try block could be anything. Is it possible
> to find the last exception raised?

try:
    func()
except (), msg:
    print msg

regards,
Gerrit.

-- 
Comparison Python GUI's: http://www.nl.linux.org/~gerrit/gui.html
Please comment!




More information about the Python-list mailing list