(continued from previous pageprint('an exception flew by!'raise an exception flew bytraceback (most recent call last)file ""line in nameerrorhithere user-defined exceptions programs may name their own exceptions by creating new exception class (see classes for more about python classesexceptions should typically be derived from the exception classeither directly or indirectly exception classes can be defined which do anything any other class can dobut are usually kept simpleoften only offering number of attributes that allow information about the error to be extracted by handlers for the exception when creating module that can raise several distinct errorsa common practice is to create base class for exceptions defined by that moduleand subclass that to create specific exception classes for different error conditionsclass error(exception)"""base class for exceptions in this module ""pass class inputerror(error)"""exception raised for errors in the input attributesexpression -input expression in which the error occurred message -explanation of the error ""def __init__(selfexpressionmessage)self expression expression self message message class transitionerror(error)"""raised when an operation attempts state transition that' not allowed attributesprevious -state at beginning of transition next -attempted new state message -explanation of why the specific transition is not allowed ""def __init__(selfpreviousnextmessage)self previous previous self next next self message message most exceptions are defined with names that end in "error,similar to the naming of the standard exceptions many standard modules define their own exceptions to report errors that may occur in functions they define more information on classes is presented in classes user-defined exceptions