| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- concurrency
- 시바견
- Substring with Concatenation of All Words
- 파이썬
- Decorator
- attribute
- DWG
- Regular Expression
- 715. Range Module
- 프로그래머스
- 컴퓨터의 구조
- Python Code
- kaggle
- Generator
- LeetCode
- t1
- Python Implementation
- data science
- 315. Count of Smaller Numbers After Self
- shiba
- iterator
- Convert Sorted List to Binary Search Tree
- Protocol
- Class
- 밴픽
- 운영체제
- 43. Multiply Strings
- 30. Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
- Python
- Today
- Total
목록Protocol (2)
Scribbling
What is interface? Interface is a set of public methods. In python, 'X object', 'X protocol' and 'X interface' have the same meaning. In Python, protocol is pretty dynamic. In below example, FrenchDeck class does not inherit any class (other than default 'object' class). However, the class has sequential protocol as it has two magic methods (__len__, __getitem__). Likewise, in Python, object's d..
To learn sequence protocol in Python, we create a custom vector class. from array import array import math import reprlib class Vector: typecode = 'd' def __init__(self, components): self._components = array(self.typecode, components) def __iter__(self): return iter(self._components) def __repr__(self): components = reprlib.repr(self._components) components = components[components.find('['):-1] ..