messages--any constructor arguments are attached to the instance and displayed when the instance is printedraise indexerror traceback (most recent call last)file ""line in indexerror same as indexerror()no arguments raise indexerror('spam'traceback (most recent call last)file ""line in indexerrorspam constructor argument attachedprinted indexerror('spam' args ('spam',print(ispam available in object attribute displays args when printed manually the same holds true for user-defined exceptions in python (and for new-style classes in )because they inherit the constructor and display methods present in their builtin superclassesclass (exception)pass raise traceback (most recent call last)file ""line in __main__ raise ('spam'traceback (most recent call last)file ""line in __main__ espam ('spam' args ('spam',print(ispam when intercepted in try statementthe exception instance object gives access to both the original constructor arguments and the display methodtryraise ('spam'except as xprint(xprint( argsprint(repr( )spam ('spam', ('spam', exception objects displays and saves constructor arguments