0
나는 아래와 같이 간단한 데코레이터를 사용합니다. 그러나 파이썬 파일을 가져 오면 즉시 실행되고 함수를 다시 호출 할 수 없습니다. 데코레이터는 어떻게 사용 되나요? 이 사용다른 파일에서 꾸미기 가져 오기 및 사용하기
def plain_decorator(func):
def decorated_func():
print "Decorating"
func()
print "Decorated"
return decorated_func()
@plain_decorator
def hw():
print "Hello Decorators!"
>>> import decorator_ex2 as d
Decorating
Hello Decorators!
Decorated
>>> d.hw()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
>>>