일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 109. Convert Sorted List to Binary Search Tree
- shiba
- 파이썬
- DWG
- iterator
- 30. Substring with Concatenation of All Words
- 43. Multiply Strings
- 운영체제
- Substring with Concatenation of All Words
- Python Code
- t1
- 밴픽
- Convert Sorted List to Binary Search Tree
- 715. Range Module
- LeetCode
- Generator
- concurrency
- 315. Count of Smaller Numbers After Self
- data science
- Class
- Regular Expression
- 프로그래머스
- Protocol
- kaggle
- 시바견
- Python
- 컴퓨터의 구조
- attribute
- Decorator
- Python Implementation
Archives
- Today
- Total
목록데코레이터 (1)
Scribbling
<Python> Decorator
Decorator는 이미 만든 함수를 수정하지 않고, 함수 주변을 감싸는 방식으로 함수에 추가 기능을 구현한다. def trace(func): # wrapper는 아래처럼 가변 인수로 만들 수 있다. # 가변 인수가 아닌 경우, 원래 함수의 parameter 형태와 일치해야 한다. def wrapper(*args, **kwargs): ret = func(*args, **kwargs) print('{0}(args={1}, kwargs={2}) -> {3}'.format(func.__name__, args, kwargs, ret)) # 원래 함수가 return이 필요한 경우에는 wrapper도 return이 필요하다. return ret return wrapper @trace def get_max(*args..
Computer Science/Python
2021. 11. 9. 21:03