일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Substring with Concatenation of All Words
- iterator
- Convert Sorted List to Binary Search Tree
- Decorator
- Generator
- attribute
- 315. Count of Smaller Numbers After Self
- 109. Convert Sorted List to Binary Search Tree
- 30. Substring with Concatenation of All Words
- 715. Range Module
- concurrency
- 파이썬
- Regular Expression
- data science
- 컴퓨터의 구조
- 프로그래머스
- Class
- Python Implementation
- shiba
- t1
- Python Code
- Python
- 운영체제
- DWG
- 43. Multiply Strings
- Protocol
- kaggle
- LeetCode
- 시바견
- 밴픽
Archives
- Today
- Total
목록metaprogramming (1)
Scribbling
Python: Class Metaprogramming (클래스 메타프로그래밍)
클래스 메타프로그래밍은 실행 도중에 클래스를 생성하거나 커스터마이징 하는 기술이다. 클래스 데코레이터와 메타클래스는 이를 위한 방법이다. 메타클래스는 강력하지만, 어렵다. 클래스 데커레이터는 사용하기 쉽지만, 상속 계층 구조가 있는 경우에는 사용하기 어렵다. 1. 런타임에 클래스 생성하기 파이썬 표준 라이브러리에는 collections.namedtuple 이라는 클래스 팩토리가 있다. 클래스명과 속성명을 전달하면 이름 및 점 표기법으로 항목을 가져올 수 있다. 유사한 클래스 팩토리를 만들면서 런타임에 클래스 생성하는 방법을 확인해보자. def record(cls_name, field_names): try: field_names = field_names.replace(',', '').split() exce..
Computer Science/Python
2022. 6. 17. 16:51