property()1 properties 출처: https://www.pythontutorial.net/python-oop/python-properties/ Introduction to class properties 다음은 이름과 나이라는 두 가지 속성이 있는 Person 클래스를 정의하고 Person 클래스의 새 인스턴스를 만듭니다. class Person: def __init__(self, name, age): self.name = name self.age = age john = Person('John', 18) age는 Person 클래스의 인스턴스 속성이므로 다음과 같이 새 값을 할당할 수 있습니다. john.age = 19 다음 할당도 기술적으로 유효합니다. john.age = -1 그러나 나이는 의미상 올바르지 않습니다. 나이가 0 .. 2023. 4. 4. 이전 1 다음