250x250
반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- grad-cam
- youtube data
- TensorFlow
- airflow subdag
- flask
- XAI
- Retry
- integrated gradient
- requests
- UDF
- top_k
- API
- GenericGBQException
- subdag
- gather_nd
- Counterfactual Explanations
- API Gateway
- correlation
- hadoop
- GCP
- login crawling
- 유튜브 API
- BigQuery
- chatGPT
- 상관관계
- session 유지
- spark udf
- tensorflow text
- 공분산
- Airflow
Archives
- Today
- Total
데이터과학 삼학년
데커레이터 다수 지정할때 실행 순서?! 본문
반응형
데커레이터가 여러개 있는 경우, 실행순서는 어떻게 될까?
@데코레이터1
@데코레이터2
def 함수이름():
코드
함수 위에 데커레이터를 여러 줄로 지정된 경우,
데커레이터가 실행되는 순서는 위에서 아래 순으로 실행!
def decorator1(func):
def wrapper():
print('decorator1')
func()
return wrapper
def decorator2(func):
def wrapper():
print('decorator2')
func()
return wrapper
# 데코레이터를 여러 개 지정
@decorator1
@decorator2
def hello():
print('hello')
hello()
#=========
decorator1
decorator2
hello
출처 : dojang.io/mod/page/view.php?id=2427
파이썬 코딩 도장: 42.1 데코레이터 만들기
Unit 42. 데코레이터 사용하기 파이썬은 데코레이터(decorator)라는 기능을 제공합니다. 데코레이터는 장식하다, 꾸미다라는 뜻의 decorate에 er(or)을 붙인 말인데 장식하는 도구 정도로 설명할 수 있습
dojang.io
728x90
반응형
LIST
'Python' 카테고리의 다른 글
f-string escape string (중괄호를 나오게 하려면) (0) | 2021.06.17 |
---|---|
클래스를 이용하여 데커레이터 만들기 (0) | 2021.04.15 |
정규 표현식 기초 (퍼옴) (0) | 2021.03.23 |
코루틴 (coroutine) 정리 (1) | 2021.01.01 |
순열과 조합 구하기 (Permutation & Combination) (0) | 2020.11.28 |
Comments