IT
[python]__init __ () 메소드로 파이썬 슈퍼 () 이해 [중복]
__init __ () 메소드로 파이썬 슈퍼 () 이해 [중복] 질문 왜 슈퍼 ()가 사용됩니까?Base .__ init__와 super () .__ init__ 사이에 차이가 있습니까?class Base(object): def __init__(self): print "Base created" class ChildA(Base): def __init__(self): Base.__init__(self) class ChildB(Base): def __init__(self): super(ChildB, self).__init__() ChildA() ChildB() 답변 슈퍼 ()를 사용하면 기본 클래스를 명시 적으로 언급하지 않으므로 멋지게 될 수 있습니다.그러나 주요 이점은 여러 가지 상속이 제공됩니다. 모든 ..
2022. 4. 8. 10:39
최근댓글