1. Common exception names
Attributeerror the exception that is thrown by calling a method that does not exist.
Eoferror encountered an exception thrown at the end of the file.
Importerror the exception that was thrown when the import module was faulted.
Indexerror the exception that is thrown by the list out of bounds.
IOError an I/O operation throws an exception, such as an error opening file.
Keyerror throws an exception with a keyword that does not exist in the dictionary.
Nameerror throws an exception with a variable name that does not exist.
Taberror the exception that is thrown by the statement block indentation incorrectly.
ValueError the exception that is thrown by a value that does not exist in the search list.
The Zerodivisionerror divisor is a zero-thrown exception.
2. Syntax
Try
... guarded clause ...
Except expression ...:
... exception handler Codee ...
Finally
... clean-up code ...
3. Raise statements
def crossproduct (seq1, SEQ2):
If not seq1 and not SEQ2:
Raise ValueError, "Sequence arguments must be non-empty."
return [(x, Y) for X1 in seq1 for X2 in SEQ2]
Python exception record