Property()1 property (함수/데코레이터)[파이썬/python] -목차- 1. 필드명 2. Getter/Setter 3. Property() 함수 4. @Property 데코레이터 5. @Property 데코레이터 활용 1. 필드명 사람의 이름, 성, 나이 데이터를 담기 위한 간단한 클래스를 하나 작성해보자. 아래 Person 클래스는 이름 first_name, last_name, age 이렇게 3개의 필드로 이루어져 있다. class Person: def __init__(self, first_name, last_name, age): self.first_name = first_name self.last_name = last_name self.age = age Person 클래스의 인스턴스를 생성 후에, 현재 필드 값을 읽거나 새로운 필드 값 쓰는 것은 매우 자유롭다... 2022. 2. 17. 이전 1 다음