@classmethod 완벽 이해
이해가 잘 안돼서 찾아보다가 발견한 동영상 입니다.
몇번 보니 이해가 조금(?) 되네요. (머리가 나빠서요 ㅎ)
https://youtu.be/MP-MXkQPrEc
[code]
class Member():
_ins = []
def __init__(self, name, height, weight, fat):
self.name = name
self.height = height
self.weight = weight
self.fat = fat
self.add_instance(self)
@classmethod
def add_instance(cls, ins):
cls._ins.append(ins)
a = Member("kim", 180, 77, 24)
b = Member("Ihm", 170, 71, 16)
c = Member("Choi", 160, 51, 23)
d = Member("Park", 170, 63, 20)
height_mean = sum([m.height for m in Member._ins]) / len(Member._ins)
print(f"height_mean = {height_mean}")
[/code]
게시판 목록
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 91 | 5년 전 | 1162 | ||
| 90 | 5년 전 | 1294 | ||
| 89 | 5년 전 | 1858 | ||
| 88 | 5년 전 | 1894 | ||
| 87 | 5년 전 | 28250 | ||
| 86 | 5년 전 | 1424 | ||
| 85 | 5년 전 | 1292 | ||
| 84 | 5년 전 | 1311 | ||
| 83 | 5년 전 | 964 | ||
| 82 | 5년 전 | 1342 | ||
| 81 | 5년 전 | 1750 | ||
| 80 | 5년 전 | 1739 | ||
| 79 | 5년 전 | 1669 | ||
| 78 | 5년 전 | 1576 | ||
| 77 | 5년 전 | 1275 | ||
| 76 | 5년 전 | 1779 | ||
| 75 | 5년 전 | 1796 | ||
| 74 | 5년 전 | 3252 | ||
| 73 | 5년 전 | 3417 | ||
| 72 | 5년 전 | 2506 | ||
| 71 | 5년 전 | 1846 | ||
| 70 | 5년 전 | 2708 | ||
| 69 | 5년 전 | 1454 | ||
| 68 | 5년 전 | 1383 | ||
| 67 | 5년 전 | 1240 | ||
| 66 | 5년 전 | 1603 | ||
| 65 | 5년 전 | 2067 | ||
| 64 | 5년 전 | 1809 | ||
| 63 | 5년 전 | 1316 | ||
| 62 | 5년 전 | 1158 |

댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기