我有这段代码,它可以计算两个坐标之间的距离。这两个函数都在同一个类中。
但是,我该如何在函数 isNear
中调用函数 distToPoint
?
class Coordinates:
def distToPoint(self, p):
"""
Use pythagoras to find distance
(a^2 = b^2 + c^2)
"""
...
def isNear(self, p):
distToPoint(self, p)
...