def hello_world(fn):
print('hello world')
fn()
pass
@hello_world
def decorate():
print('hello decoatrion')
return
decorate()
내가 목표로 한 '안녕하세요 장식'전에 '안녕하세요'를 인쇄하는,하지만 출력은 다음과 같다 :
hello world
hello decoatrion
Traceback (most recent call last):
File "test_decortor.py", line 11, in <module>
decorate()
TypeError: 'NoneType' object is not callable
그래, 뭐가 궁금한가요? – melpomene
가능한 [Python에서 함수 데코레이터 체인을 만들 수 있습니까?] (http://stackoverflow.com/questions/739654/how-can-i-make-a-chain-of-function-decorators-in -python) – GingerPlusPlus
데코레이터가 장식 된 함수가 아닌'None'을 반환합니다. [이 예제들] (https://docs.python.org/3/whatsnew/2.4.html#pep-318-decorators-for-functions-and-methods)과 [PEP 318 - 함수 데코레이터 , Methods and Classes] (https://www.python.org/dev/peps/pep-0318/) 그 자체. – martineau