multiple arguments save/display tuple raise ('spam''eggs''ham'except as xprint('% % (xx args)('spam''eggs''ham'('spam''eggs''ham'note that exception instance objects are not strings themselvesbut use the __str__ operator overloading protocol we studied in to provide display strings when printedto concatenate with real stringsperform manual conversionsstr( 'as tr''%sxand the like although this automatic state and display support is useful by itselffor more specific display and state retention needs you can always redefine inherited methods such as __str__ and __init__ in exception subclasses--as the next section shows custom print displays as we saw in the preceding sectionby defaultinstances of class-based exceptions display whatever you passed to the class constructor when they are caught and printedclass mybad(exception)pass tryraise mybad('sorry--my mistake!'except mybad as xprint(xsorry--my mistakethis inherited default display model is also used if the exception is displayed as part of an error message when the exception is not caughtraise mybad('sorry--my mistake!'traceback (most recent call last)file ""line in __main__ mybadsorry--my mistakefor many rolesthis is sufficient to provide more custom displaythoughyou can define one of two string-representation overloading methods in your class (__repr__ or __str__to return the string you want to display for your exception the string the method returns will be displayed if the exception either is caught and printed or reaches the default handlerclass mybad(exception)def __str__(self)return 'always look on the bright side of life tryraise mybad(except mybad as xprint(xcustom print displays