Errors in Python: Syntax, Runtime and Logical
Three kinds of error, found at three different moments. Only one of them can be caught, and the one that catches nobody out is the most dangerous.
Syntax, runtime and logical errors, try, except, else and finally, the exception hierarchy, raise and custom exception classes.
4 notes
Three kinds of error, found at three different moments. Only one of them can be caught, and the one that catches nobody out is the most dangerous.
try runs risky code, except handles a failure, else runs when nothing failed, and finally always runs. Each block has one job and using the wrong one...
Every exception is a class in one inheritance tree. Catching a parent catches all its children, which is what makes handler order and handler width ma...
raise signals a failure your own code has detected. A custom exception class gives that failure a name callers can catch precisely.