Python exception record and Python record
1. Common Exception name
AttributeError indicates an exception caused by calling a method that does not exist.
EOFError encountered an exception at the end of the file.
Exception caused by an error in the ImportError import module.
An exception occurs when the IndexError list is out of bounds.
IOError I/O operations, such as file opening errors.
KeyError indicates an exception caused by a keyword that does not exist in the dictionary.
NameError indicates an exception caused by a nonexistent variable name.
An exception caused by incorrect TabError block indentation.
Exception caused by a value that does not exist in the ValueError search list.
An exception caused by zero ZeroDivisionError.
2. Syntax
Try:
... Guarded clause...
Struct t... expression ...:
... Exception handler codee...
Finally:
... Clean-up code...
3. raise statement
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]