property 데코레이터
·
[Language] - Python
개요작업을 하던 도중 처음보는 데코레이터를 발견했다.. 보통 우리는 객체의 필드에 직접 접근하는 것을 방지하기 위해 protected나 private 접근제한자를 사용하고, getter와 setter를 통해서만 접근할 수 있도록 캡슐화(Encapsulation)을 한다. 이러한 과정을 간소화 시켜주는 것이 프로퍼티의 역할이다. 사용 예시class Palette: def __init__(self): self.__color = 'blue' def get_color(self): return self.__color def set_color(self, color): self.__color = color def del_color(self): ..