Why are Python exceptions named "Error" (e.g. ZeroDivisionError, NameError, TypeError)?

PythonServer Side ProgrammingProgramming

We see that most exceptions have their names ending in word ‘error’ pointing that they are errors which is the meaning of exceptions anyway.

Errors in restricted sense are taken to mean syntax errors in python and those errors occurring at run time are called exceptions. As we know that classes do not have ‘class’ in their name; and similarly variables do not have names ending in ‘variable’ and so on. So there is no case that exceptions should have names ending in the word ‘exception’.

Consider this; not all exceptions are errors. SystemExit, KeyboardInterrupt, StopIteration, GeneratorExit are all exceptions and not errors. Indeed, there are a number of exceptions that derive from an exception class named Warning.

One good motivation in naming exceptions with the word ‘error’ may be that it is shorter than ‘exception’ in length and can save few characters in the code without loss of meaning.

Published on 06-Dec-2017 17:55:35