I'd like to overload a method move in a class Point
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def move(self, other_point):
...
def move(self, x, y):
...
The following way is not meaningful because x will be a Point object if y is not provided.
def move(self, x, y=None):
if y is None:
other = x
self.x += other.x
self.y += other.y
else:
self.x += x
self.y += y
I'm not happy with the parameter name in the following way either.
def move(self, *param):
if len(p) == 1:
other = param[0]
self.x += other.x
self.y += other.y
else:
self.x += param[0]
self.y += param[1]
What is the best way to overload the method move?