Multiple inheritence for exceptions?

  • Thread starter Steven D'Aprano
  • Start date
S

Steven D'Aprano

Useful or a bad idea?

I have a module that defines a number of exceptions which inherit from
various built-ins like KeyError, ValueError etc. I'm considering defining
an abstract module exception like MyModuleError, and having all my real
exceptions inherit from it as well, but I don't recall seeing that done
before and I was wondering if it were a bad idea for some reason.
 
A

Alex Martelli

Steven D'Aprano said:
Useful or a bad idea?

I have a module that defines a number of exceptions which inherit from
various built-ins like KeyError, ValueError etc. I'm considering defining
an abstract module exception like MyModuleError, and having all my real
exceptions inherit from it as well, but I don't recall seeing that done
before and I was wondering if it were a bad idea for some reason.

I often do exactly what you propose, and I believe I have suggested it
in the Nutshell 2nd edition. I have never observed bad effects.


Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top