일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 시바견
- Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- t1
- Protocol
- 43. Multiply Strings
- 운영체제
- 밴픽
- Generator
- shiba
- DWG
- concurrency
- kaggle
- attribute
- iterator
- LeetCode
- Convert Sorted List to Binary Search Tree
- Python Code
- Python Implementation
- Python
- Class
- 파이썬
- 프로그래머스
- 컴퓨터의 구조
- data science
- 715. Range Module
- Regular Expression
- 30. Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
Archives
- Today
- Total
목록Magic (1)
Scribbling
Python Magic Methods: Pythonic Data Model
In this post, I am dealing with 'magic methods' to create more pythonic data models. First Example: Card Deck Card = namedtuple('Card', ['rank', 'suit']) class FrenchDeck: ranks = [str(n) for n in range(2, 11)] + list('JQKA') suits = ['Spades', 'Diamonds', 'Hearts', 'Clubs'] def __init__(self): self._cards = [Card(rank, suit) for suit in FrenchDeck.suits for rank in FrenchDeck.ranks] def __len__..
Computer Science/Python
2022. 3. 16. 13:54