title: Python: AttributeError: 'Point' object has no attribute 'x'
body: <pre><code>Traceback (most recent call last):
  line 56, in &lt;module&gt;
      distanceToOne = point1.Distance(pointUser)
  line 22, in Distance
      distance = math.sqrt((self.__x - toPoint.x)**2 +(self.__y - toPoint.y)**2 +(self.__z - toPoint.z)**2)
  AttributeError: 'Point' object has no attribute 'x'
  </code></pre>
  
  <p>For some reason I keep getting the above error message whenever I get to: <code>distanceToOne = point1.Distance(pointUser)</code> after grabbing my three points to calculate the distance from.</p>
  
  <p>Here is a better view if needed: <a href="http://pastie.org/private/vige6oaphkwestdemr5uw" rel="nofollow">http://pastie.org/private/vige6oaphkwestdemr5uw</a></p>
  
  <p>Thanks in advance for your help!</p>
  
  <pre><code>import math
  class Point(object):
      def __init__(self, x = 0, y = 0, z = 0, description = 'TBD'):
          self.__x = x
          self.__y = y
          self.__z = z
          self.__description = description
  
      def SetPoint(self, coords):
          self.__x = coords[0]
          self.__y = coords[1]
          self.__z = coords[2]
  
      def GetPoint(self):
          return [self.__x, self.__y, self.__z]
      PointCoords = property(GetPoint, SetPoint)
  
      def Distance(self, toPoint):
          toPoint.PointCoords[0]
          toPoint.PointCoords[1]
          toPoint.PointCoords[2]
          return math.sqrt(
              (self.__x - toPoint.x)**2 +
              (self.__y - toPoint.y)**2 +
              (self.__z - toPoint.z)**2)
  
      def SetDescription(self, description):
          self.__description = description
  
      def GetDescription(self):
          return self.__description
      PointDescription = property(GetDescription, SetDescription)
  
  if __name__ == "__main__":
      print "Program 9: Demonstrate how to define a class"
  
      point2 = Point()
      point1 = Point(10, 54, 788, 'Ploto')
      point2.PointCoords = 77, 2, 205
      point2.PointDescription = 'Mars'
      doAnother = "y"
      while(doAnother == "y"):
          pointX = raw_input("Enter a X Number: ")
          pointY = raw_input("Enter a Y Number: ")
          pointZ = raw_input("Enter a Z Number: ")
  
          # Constructor - Represent the user's location
          pointUser = Point(pointX, pointY, pointZ, 'Sun')
  
          distanceToOne = point1.Distance(pointUser)
          distanceToTwo = point2.Distance(pointUser)
  
          # Comparing the two distances between the two to see which one is the closest
          if (distanceToOne &gt; distanceToTwo):
              closest = point2
          else:
              closest = point1
              print ('You are closest to',closest.PointDescription(), 'which is located at ',closest.PointCoords())
          doAnother = raw_input("Do another (y/n)? ").lower()
      print ('Good Bye!')
  </code></pre>