[Python-Dev] Pre-PEP: Exception Reorganization for Python 3.0
Brett Cannon
bcannon at gmail.com
Tue Aug 2 02:03:54 CEST 2005
On 8/1/05, Delaney, Timothy (Tim) <tdelaney at avaya.com> wrote:
> Nick Coghlan wrote:
>
> > +-- Exception (formerly StandardError)
> > +-- AttributeError
> > +-- NameError
> > +-- UnboundLocalError
> > +-- RuntimeError
> > +-- NotImplementedError
>
> Time to wade in ...
>
> I've actually been wondering if NotImplementedError should actually be a
> subclass of AttributeError.
>
> Everywhere I can think of where I would want to catch
> NotImplementedError, I would also want to catch AttributeError. My main
> question is whether I would want the reverse to also be true - anywhere
> I want to catch AttributeError, I would want to catch
> NotImplementedError.
>
> Perhaps instead it should be the other way around - AttributeError
> inherits from NotImplementedError. This does make some kind of sense -
> the attribute hasn't been implemented.
>
> Both seem to have some advantages, but neither really feels right to me.
> Thoughts?
The problem with subclassing NotImplementedError is you need to
remember it is used to signal that a magic method does not work for a
specific type and thus should try the __r*__ version. That is not a
case, I feel, that has anything to do with attributes but
implementation support.
I am not going to subclass NotImplementedError unless a huge push for
it in a very specific direction.
-Brett (who is waiting on a PEP number...)
More information about the Python-Dev
mailing list