파이썬에서 Getter/Setter 패턴 사용하기
class를 사용하는 언어들(C++, python, java 등등)에서 Class를 생성하게 되면, Getter Setter 패턴을 만들게 된다. class Shoulder: def __init__(self,shoulder_x): self.__shoulder_x = shoulder_x def get_shoulder_x(self): return self.__shoulder_x def set_shoulder_x(self,value): self.__shoulder_x = value 보통 위와 같이 코드를 작성하게 되는데, 이런 코드의 경우 가져올때, 아래와 같이 가져오게 되는데, 이 경우 직관적이지 못하다는 단점이 있다. left_shoulder = Shoulder() left_shoulder.set_shou..
2021.03.15