-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuper2.py
More file actions
28 lines (21 loc) · 1.35 KB
/
Copy pathSuper2.py
File metadata and controls
28 lines (21 loc) · 1.35 KB
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
# ------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------super의 다중 상속의 개념만 작성함--------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------------
class Unit():
def __init__(self):
print("Unit 생성자")
class Flyable():
def __init__(self):
print("Flyable 생성자")
class FlyableUnit(Unit, Flyable):
def __init__(self):
# super().__init__() # 다중 상속을 하려고 했지만 마지막에 있는 클래스는 정의 되지 않는다.
# 다중 상속일 땐, 아래처럼 해야한다.
Unit.__init__(self)
Flyable.__init__(self)
# 드랍쉽으로 예제를 보이면...
dropship = FlyableUnit() # 즉, Unit class에 투입돼 초기화가 되었지만 Flyable class에는 투입되지않아 초기화 되지 않았다.
# 출력물 : Unit 생성자
# 반대로 FlyableUnit(Unit, Flyable) --> FlyableUnit(Flyable, Unit)하면
# 출력물 : Flyable 생성자
# Flyable class에 투입돼 초기화가 되었지만 Unit class에는 투입되지않아 초기화 되지 않았다.