첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ 클래스의 super 함수를 사용해 상위 클래스 메소드를 호출하는 방법을 보여준다.

 

▶ 예제 코드 (PY)

class Animal:
    def __init__(self):
        print("Animal __init__()")

class Tiger(Animal):
    def __init__(self):
        super().__init__()
        print("Tiger __init__()")

class Lion(Animal):
    def __init__(self):
        super().__init__()
        print("Lion __init__()")

class Liger(Tiger, Lion):
    def __init__(self):
        super().__init__()
        print("Liger __init__()")

liger = Liger()

"""
Animal __init__()
Lion __init__()
Tiger __init__()
Liger __init__()
"""
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요