Which exception has been used? (was: Which exception to use?)
op73418 at mail.telepac.pt
Fri Jan 31 01:10:16 CET 2003
On Thu, 30 Jan 2003 22:43:15 -0000, claird at lairds.com (Cameron Laird)
>One of my problems is that I don't know how to write
>"the default case". When we see the above, I assume
>we all have in mind client code that looks like
> except SpecializedError, e:
> except StandardError, e:
>Suppose, as is always true, though, that I'm dealing
>with modules not under my control. How do I catch
>"other"? There must be something I'm missing about
>the new type and exception systems, 'cause I don't
>see a Pythonic way to write
> except OTHER, e:
> # The foreign code threw an exception of
> # a type I don't recognize, but I need
> # to process/log/... 'e'.
>Yes, I can write
>but then I've lost the information I want in 'e'.
Does this solve your problem?
... raise TypeError("This is a whacky example!")
... except Exception, e:
... print e
This is a whacky example!
More information about the Python-list