스태틱메소드와 클래스메소드
미해결
타입 파이썬! 올바른 class 사용법과 객체지향 프로그래밍
그 클래스 메소드와 스태틱메소드의 실사용례는 이러할까요? 약간 스태틱메소드는 상속받아도 변하지 않는 것과 관련된 메소드에 사용하고 클래스메소드는 상속받으면 변할 수 있는것과 관련되 메소드에 사용하는? 이에 대한 이해는 이부분 을 참고했습니다. # Online Python compiler (interpreter) to run Python online. # Write Python 3 code in this online editor and run it. class wooden_furniture: ingredient = "wooden" furniture = "furniture" @staticmethod def get_ingredient(): print("made_by_wooden") return "made_by_wooden" @classmethod def get_furniture(cls): print( f"{cls.furniture}") return "class" class wooden_table(wooden_furniture): def __init__(self): self.furniture = "table" table = wooden_table() furniture = wooden_furniture() table.get_ingredient() table.get_furniture() furniture.get_ingredient() furniture.get_furniture()
- 파이썬
- python
- 스태틱
- 클래스
- oop





