Jan-10-2021, 10:06 AM
Is it possible to use more than 2 parameters for magic methods/Dunders for arithmetic operators? The following is my code
class Point(): def __init__(self, x, y): self.x = x self.y = y def __str__(self): return f"Point ({self.x}, {self.y})" def __add__(self, other): return Point(self.x+other.x, self.y+other.y) point = Point(1, 2) other = Point(3, 5) print(point+other)I want to get something like
def __add__(self, other, something_else): return Point(self.x+other.x+something_else.x, self.y+other.y+something_else.y)Also, for some reason the indentations dont show, so please ignore that :)