title: AttributeError in constructor of class in python
body: <p>I'm fairly new to Python and I'm working with classes(in Python) for the first time. When I try to use the constructor, I get an AttributeError, though I'm not really sure why this is occurring.</p>
  
  <pre><code>class Pawn(object):
  
      def __init__(self, x: int, y: int):
          if (not x in range(1,9)):
              raise ValueError('Invalid X-Position')
          if (not y in range(1,9)):
              raise ValueError('Invalid Y-Position')
          self.x = x
          self.y = y
  
      @staticmethod
      def parseFromString(sPawn):
          try:
              return Pawn(ord(sPawn[0]) - 96, int(sPawn[1]))
          except ValueError:
              raise ValueError('Parse Failed. Please check pawn string.')
  
      def getLethals(self):
          lethals = {}
  
          try:
              lethals.append(Pawn(self.x - 1, self.y))
              lethals.append(Pawn(self.x + 1, self.y))
              lethals.append(Pawn(self.x, self.y - 1))
              lethals.append(Pawn(self.x, self.y + 1))
              lethals.append(Pawn(self.x - 1, self.y - 1))
              lethals.append(Pawn(self.x + 1, self.y + 1))
              lethals.append(Pawn(self.x - 1, self.y + 1))
              lethals.append(Pawn(self.x + 1, self.y - 1))
          except ValueError:
              pass
  
          return lethals
  
      def packToString(self):
          return str(chr(self.x + 96)) + str(self.y)
  
      @property
      def x(self):
          return self.x
  
      @property
      def y(self):
          return self.y
  </code></pre>
  
  <p>When I try to create an instance:</p>
  
  <pre><code>def testFunc():
      pawn = Pawn(2,4)
  </code></pre>
  
  <p>I get an:</p>
  
  <pre><code>AttributeError: can't set attribute
  </code></pre>
  
  <p>Tracing all the way back to 'self.x = x' of the constructor of 'Pawn'.</p>
  
  <p>EDIT: I didn't understand that properties revoked writing privileges of class variables. I will add setters.</p>