I come from Java where Exceptions and Errors are quite different things and they both derive from something called Throwable. In Java normally you should never try to catch an Error.
In Python though it seems the distinction is blurred.
So far after reading some docs and checking the hierarchy I have the following questions:
There are syntax errors which of course cause your program not to be able to start at all. Right?
"Errors detected during execution are called exceptions and are not unconditionally fatal" (per the tutorial). What does "fatal" mean here? Also, some objects like
AttributeErrorare (by the above definition) actually exceptions even though they contain Error in their names, is that conclusion correct?Some classes derive from
Exceptionbut contain Error in their name. Isn't this confusing? But even so it means that Error in the name is in no way special, it's still an Exception. Or not... ?"All built-in, non-system-exiting exceptions are derived from [Exception]" (quote from here)
So which ones are system-exiting exceptions and which ones are not? It is not immediately clear. All user-defined exceptions should also be derived from Exception. So basically as a beginner do I need to worry about anything else but Exception? Seems like not.Warnings also derive from Exception. So are warnings fatal or system-exiting or none of these?
Where does the
AssertionErrorfit into all of this? Is it fatal or system exiting?How does one know or specify that some Exception class represents fatal or system-exiting exception?
try..catch. In that sense, Python doesn't make that distinction. Every possible error is an exception and can be handled viatry..except.