How to call a function within class?

前端 未结 2 774
暗喜
暗喜 2020-11-21 23:37

I have this code which calculates the distance between two coordinates. The two functions are both within the same class.

However how do I call the function di

2条回答
  •  盖世英雄少女心
    2020-11-22 00:34

    Since these are member functions, call it as a member function on the instance, self.

    def isNear(self, p):
        self.distToPoint(p)
        ...
    

提交回复
热议问题