def line(self)print(self name ':'repr(self says())class customer(actor)name 'customerdef says(self)return "that' one ex-bird!class clerk(actor)name 'clerkdef says(self)return "no it isn' class parrot(actor)name 'parrotdef says(self)return none class scenedef __init__(self)self clerk clerk(self customer customer(self subject parrot(def action(self)self customer line(self clerk line(self subject line(embed some instances scene is composite delegate to embedded part viiexceptions and tools see "test your knowledgepart vii exerciseson page in for the exercises try/except my version of the oops function (file oops pyfollows as for the noncoding questionschanging oops to raise keyerror instead of an indexerror means that the try handler won' catch the exception--it "percolatesto the top level and triggers python' default error message the names keyerror and indexerror come from the outermost built-in names scope (the in "legb"import builtins in (and __builtin__ in python xand pass it as an argument to the dir function to see this for yourself def oops()raise indexerror(def doomed()tryoops(except indexerrorprint('caught an index error!'elseprint('no error caught 'if __name__ ='__main__'doomed(part viiexceptions and tools