.으로 접근할 수 있는 딕셔너리
```python
class dotdict(dict):
def __getattr__(self, name):
return self[name]
클래스 메서드에서 어떤 값을 초기 한 번만 계산하고 이후 호출에서는 단순히 반환만 하고 싶을 때
2018/08/07 - [Coding Syntax/Python] - [python] @property와 property() 클래스
2019/02/04 - [Coding Syntax/Python] - 파이썬에는 확장 함수가 없다. 어떤 클래스에 추가 기능이 필요한 경우.
파이썬에서 클로저 사용하기
@dump 데커레이터
dump 데커레이터
```python
def dump(func):
def wrapped(*args, **kwargs):
print("func name: {}".format(func.__name__))
print("args : {}".format(' '.join(map(str, args))))
print("kwargs : {}".format(kwargs.items()))
output = func(*args, **kwargs)
print("output : {}".format(output))
return output
return wrapped
```
vars() 키워드
```python
>>> def a(a):
... print(vars())
...
>>> a(3)
{'a': 3}
```
'Coding Syntax > Python' 카테고리의 다른 글
[python] 사용하면 좋은 패턴들 (0) | 2019.02.11 |
---|---|
헷갈리는 모듈 스코프 변수, 전역 변수처럼 쓸 수 있을까? - class level 변수를 쓰자. (0) | 2019.02.04 |
파이썬에는 확장 함수가 없다. 어떤 클래스에 추가 기능이 필요한 경우. (0) | 2019.02.04 |
[python] pdb : 디버깅 (0) | 2018.11.12 |
[python] 프로파일링(profiling) (0) | 2018.11.12 |
[python] socket (0) | 2018.11.10 |