IT
[python]staticmethod와 classmethod의 차이점
staticmethod와 classmethod의 차이점 질문 @staticmethod로 장식 된 함수의 차이점은 @classmethod로 장식 된 것의 차이점은 무엇입니까? 답변 어쩌면 비트 예제 코드가 도움이 될 것입니다 : foo, class_foo 및 static_foo의 콜 시그니처의 차이점을 확인하십시오.class A(object): def foo(self, x): print(f"executing foo({self}, {x})") @classmethod def class_foo(cls, x): print(f"executing class_foo({cls}, {x})") @staticmethod def static_foo(x): print(f"executing static_foo({x})") a =..
2022. 3. 30. 13:06
최근댓글