뇌를 자극하는 파이썬 질의응답 게시판입니다.
2016-12-31
by youngki6
1400
class MyDecorator:
def __init__(self,f):
print("Initializing MyDecorator...")
self.func = f
def __call__(self):
print("Begin :{0}".format(self.func.__name__))
self.func()
print("End :{0}".format(self.func.__name__))
def print_hello():
print("Hello.")
#print_hello = MyDecorator(print_hello)
my_decorator = MyDecorator(print_hello)
#print_hello()
my_decorator()
위와 같이 수정하면 어떨까요?