title: Is there a way to update the original x and y position of an object after I move it with a method?
body: <p>I'm creating an object Block which I assign an X and Y position among other arguments, I want to be able to move it through a method <code>move()</code> by <code>x</code> and <code>y</code> units and have the original <code>x</code> and <code>y</code> position updated, so as to when I call say <code>xyRange()</code> before moving the object, I get the original <code>x</code>, <code>y</code> position, and when I do so after <code>move()</code>, I get the updated <code>x</code>, <code>y</code> position.</p>
  
  <p>Below is what I've tried but I think I'm missing some crucial aspect because I get an error that my object 'Block' has no such attribute.</p>
  
  <pre><code>    def X(self):
          x = self.xPosition
          return x
  
      def Y(self):
          y = self.yPosition
          return y
  
      def xyRange(self):
          xRange = self.X() + self.toBlock.absX()
          yRange = self.Y() + self.toBlock.absY()
          return xRange, yRange
  
      def move(self, moveX=None, moveY=None):
          absX = self.absX()
          absY = self.absY()
          self.moveX = moveX
          if(self.moveX == None):
              moveX = 0
          self.moveY = moveY
          if(self.moveY == None):
              moveY = 0
          absoluteX = absX + moveX
          absoluteY = absY + moveY
          return absoluteX, absoluteY
  
      def absX(self):
          absoluteX = self.X() + self.toBlockId.absX()
          return absoluteX
  
      def absY(self):
          absoluteY = self.Y() + self.toBlockId.absY()
          return absoluteY
  </code></pre>
  
  <p>So I have functions <code>X()</code> and <code>Y()</code> to take in the parameters from the constructor and be able to manipulate them in other functions, also <code>absX()</code> and <code>absY()</code> to track the objects actual position in the grid and <code>xyRange()</code> function that basically does the same thing but just returns the tuple of <code>x</code>, <code>y</code> parameter (lets say for convenience sake). But I can't seem to figure out how to update my original X and Y positions.</p>
  
  <p>Say I start with a <code>block1.xyRange()</code> that returns <code>(2, 2)</code>
  then I <code>block1.move(2, 2)</code>, which you'd expect when I ran <code>block1.xyRange()</code> again, would return <code>(4, 4)</code>. But if I try adding the <code>self.moveX</code> and <code>self.moveY</code> parameters from the move function to the <code>X()</code> and <code>Y()</code> function, I get an error saying that object 'Block' has no attribute 'moveX' or 'moveY'. I assume that this is because its calling itself. But I can't figure out how to fix it.</p>
  
  <p>Any suggestions would be greatly appreciated.</p>