목차
- super() 예제 - 부모/형제 클래스의 메서드/속성에 접근 허용
- super() 정의
- super() 구문
super() 예제 - 부모/형제 클래스의 메서드/속성에 접근 허용
class Parent:
def __init__(self, txt):
self.message = txt
def printmessage(self):
print(self.message)
class Child(Parent):
def __init__(self, txt):
super().__init__(txt)
x = Child("홈짱닷컴 Homzzang.com")
x.printmessage()
결과값: 홈짱닷컴 Homzzang.com
super() 정의
부모 또는 형제 클래스의 메서드・속성에 접근 허용.
※ super()함수는 '부모 클래스 나타내는 객체' 반환.
super() 구문
super()
[매개변수]
없음.