The way these classes are structured, The Line class would always take two instances of the Point class as argument. You can easily specify the type of the coming arguments to the constructor as below.
class Point(object):
def __init__(self, x, y):
self.x = x
self.y = y
class Line(object):
def __init__(self, p1: Point , p2: Point):
self.p1 = p1
self.p2 = p2
def slope(self):
return (self.p2.y - self.p1.y) / (self.p2.x - self.p1.x)
So this would be the correct way of instantiating the classes.
point1 = Point(x=3, y=4)
point2 = Point(x=5, y=6)
L1 = Line(p1=point1, p2=point2)
# now you can call the slope method on `Line` class instance like
L1.slope()
In the above example, self.p2.y would be the y value of point2 instance which is 6 in this case.