catching object
Igor V. Rafienko
igorr at ifi.uio.no
Fri Mar 14 11:21:10 EDT 2008
[ stargaming at gmail.com ]
[ ... ]
> I think inheritance is meant in reference to the Exception tree here. So,
> the uppermost class is `BaseException`. Python 3 gives this exception
> when trying to handle `object`::
>
> TypeError: catching classes that do not inherit from BaseException is
> not allowed
I realise that exceptions should inherit from Exception, but the
question is more "why isn't an instance of ValueError a match for
object, when ValueError is a subclass of object (at least in 2.5)
[ ... ]
> > So, why doesn't object match ValueError (or any other exception for that
> > matter). I am aware of "except:", but in my particular situation it is
> > eh... unsuitable.
>
> Why so?
I am writing a function that takes a function and an exception list
arguments and returns a new function that calls the original while
trapping the specified arguments. One of the applications is to make a
wrapper that ignores all of the exceptions. I thought that specifying
the exception list containing object would suffice to cover that.
Alas, no joy.
[ ... ]
ivr
--
<+Kaptein-Dah> igorr: for få parenteser
<+Kaptein-Dah> igorr: parenteser virker som lubrication under iterasjon
<+Kaptein-Dah> igorr: velkjent
More information about the Python-list
mailing list