1class Dog:
2 def __init__(self, name):
3 self.name = name
4
5 def say_name(func):
6 def decorator(*args, **kwargs):
7 # self is always the first argument
8 self = args[0]
9 print(self.name)
10 return func(*args, **kwargs)
11 return decorator
12
13 @say_name
14 def bark(self):
15 print('woof!')