human
Write me a the Python code you requested given the following:
I am working on the file "Abducted!.ipynb".
The first task is:
Using a decorator function to decorate a class, lets teach an old dog some new tricks.  Notice that do_trick, the inject method, retains access to the list of tricks thanks to add_tricks remaining in memory as a closure.
Can you write Python code for it?
assistant
#Here is the Python code you requested.

from random import choice

def add_tricks(cls):
    tricks = ["play dead", "roll over", "sit up"]
    def do_trick(self):
        return choice(tricks)
    cls.do_trick = do_trick
    return cls
    
@add_tricks
class Animal:
    
    def __init__(self, nm):
        self.name = nm

class Mammal(Animal):
    pass

obj = Animal("Rover")
print(obj.name, "does this trick:", obj.do_trick())

new_obj = Mammal("Trixy")
print(new_obj.name, "does this trick:", obj.do_trick())