class Foo(object):
def whee(self):
return 77
class Bar(Foo):
def whee(self):
return super(Bar, self).whee() + 1
class Baz(Foo):
def whee(self):
return super(self.__class__, self).whee() + 1
Bar
과 Baz
은 whee()
에 대해 동일한 결과를 반환합니다. 저는 Bar
의 문법에 익숙합니다. Baz
에 구문을 사용하지 않아야하는 이유가 있습니까?Python에서 super를 올바르게 사용 - 명시 적으로 클래스 이름을 참조해야합니까?
이 super''에'자기 .__ class__'을 통과하지 마십시오. 그렇게 간단하다면,'super'는 처음에는 그 주장을 요구하지 않았을 것입니다. – user2357112