Python @classmethod, @staticmethod 차이점
차이점은 부모 클래스에게서 상속 받을때 나타난다. 1. classmethod는 해당cls를 받아 값이 변경이되어 사용하고 2. staticmethod는 부모의 속성을 값을 그대로 받아 사용한다. 예시 class checkMethod(object): checkWord = '안녕하세요!' def __init__(self): self.greetings = '파이썬!' + self.checkWord @classmethod def classMode(cls): return cls() @staticmethod def staticMode(): return checkMethod() def printWord(self): print(self.greetings) class answer(checkMethod): checkWor..
2021.07.10