no need of name mangling for another object of the same class in python?
Question: I'm new to Python learning about name mangling(double underscore), I've done
my search and learned, but I have one question and couldn't get the answer
through searching: we don't need name mangling when dealing with another
object of the same class in a class function, right? see my test code:

    
    
    import math
    class Point:
        def __init__(self, loc_x, loc_y):
            self.__x = loc_x
            self.__y = loc_y
        def distance(self, other):
            return math.sqrt((self.__x - other.__x) * (self.__x - other.__x) + (self.__y - other.__y) * (self.__y - other.__y))
    class Point1:
        def __init__(self, loc_x, loc_y):
            self.__x = loc_x
            self.__y = loc_y
    #two points of same class
    p1 = Point(1,2)
    p2 = Point(2,3)
    print (p1.distance(p2))
    #object of another point class
    p3 = Point1(4,5)
    print (p1.distance(p3))
    


Answer: If you use double underscores to use name mangling, you can only reference
that variable in methods on that class. Anytime you write

    
    
    obj.__var
    

inside a class method, Python will replace it with

    
    
    obj.__ClassName_var
    

Where `ClassName` is the name of the class for that method.

