사용자 도구

사이트 도구


python:decorator

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
python:decorator [2018/03/17 07:46] rex8312python:decorator [2024/03/23 02:42] (현재) – 바깥 편집 127.0.0.1
줄 52: 줄 52:
 </code> </code>
      
 +===== Decorator with parameters =====
 +
 +<code python>
 +def decorator_factory(argument):
 +    def decorator(function):
 +        def wrapper(*args, **kwargs):
 +            funny_stuff()
 +            something_with_argument(argument)
 +            result = function(*args, **kwargs)
 +            more_funny_stuff()
 +            return result
 +        return wrapper
 +    return decorator
 +    
 +# https://stackoverflow.com/questions/5929107/decorators-with-parameters
 +</code>
 +
 ===== 튜토리얼 ===== ===== 튜토리얼 =====
  
   * http://www.hanbit.co.kr/network/category/category_view.html?cms_code=CMS5689111564   * http://www.hanbit.co.kr/network/category/category_view.html?cms_code=CMS5689111564
python/decorator.1521272761.txt.gz · 마지막으로 수정됨: (바깥 편집)