Python 연산자 오버로딩을 위한 스페셜 메서드 정리
연산자 오버로딩이란? 연산자 오버로딩(Operator overloading)이란, 사용자 정의 클래스에서 기존에 정의된 연산자(+, -, *, / 등)의 동작을 재정의하는 것을 말한다. 이를 통해 사용자 정의 데이터 타입에 대해 연산자를 사용하여 직관적으로 작업할 수 있다. class Number: def __init__(self, value): self.value = value def __str__(self): return str(self.value) def __add__(self, other): if isinstance(other, Number): return Number(self.value + other.value) if isinstance(other, (int, float, bool)): retu..