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 :)
Larz60+ write Jan-10-2021, 10:43 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use code tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use code tags on future posts.