title: Using Dataclass and getting AttributeError: 'int' object has no attribute 'x'
body: <p>Trying out the <a href="https://kotlinfrompython.wordpress.com/2018/04/30/python-dataclasses-a-revolution/" rel="nofollow noreferrer">code from</a>.</p>
  
  <pre><code>from dataclasses import dataclass, field, InitVar
  
  @dataclass
  class XYPoint:
      last_serial_no = 0
      x: float
      y: float = 0
      skip: InitVar[int] = 1
      serial_no: int = field(init=False)
  
      def __post_init__(self, skip):
          self.serial_no = self.last_serial_no + self.skip
          self.__class__.last_serial_no = self.serial_no
  
      def __add__(self, other):
          new = XYPoint(self.x, self. y)
          new.x += other.x
          new.y += other.y
  </code></pre>
  
  <p>Using this as a test example:</p>
  
  <pre><code>XYPoint.__add__(32,34)
  </code></pre>
  
  <p>When running the code, I am getting the error: AttributeError: 'int' object has no attribute 'x' 
  Tried adding return to the def; same error.</p>