title: How to iterate tuples passed as *args to a class method?
body: <p>I am trying to figure out why I cannot iterate through the elements of a tuple when passed into a class method as an <code>*args</code>.  I am using python 3.9.</p>
  <p>The code works as expected when calling a method not part of a class.  When I run the following code:</p>
  <pre><code>class TestClass():
  
      def addition(*args):
          result = 0
          for arg in args:
              result += arg
          return result
  
  def addition(*args):
      result = 0
      for arg in args:
          result += arg
      return result
  
  if __name__ == '__main__':
      sum = addition(2, 5, 1, 9)
      print(sum)
      
      obj = TestClass()
      sum = obj.addition(2, 5, 1, 9)
      print(sum)
  </code></pre>
  <p>The first call to <code>addition()</code> yields 17 as expected.</p>
  <p>However, the <code>obj.addition()</code> call throws the following error:</p>
  <pre><code>Exception has occurred: TypeError
   unsupported operand type(s) for +=: 'int' and 'TestClass'
    File &quot;C:\dev\sae\gitlab-metrics\test.py&quot;, line 8, in addition
      result += arg
    File &quot;C:\dev\sae\gitlab-metrics\test.py&quot;, line 24, in &lt;module&gt;
      sum = obj.addition(2, 5, 1, 9)
  </code></pre>
  <p>If I check the type:</p>
  <pre><code>print(type(args))
  </code></pre>
  <p>indicates that both <code>args</code> variables are of type <code>tuple</code>.</p>
  <p>What's interesting is when I examined the value of <code>arg</code> in the first pass of the loop, it's value is:<code>&lt;__main__.TestClass object at 0x00000206F2CFC6A0&gt;</code></p>
  <p>This just happens to be the same address as <code>args</code>.</p>
  <p>It's like the for loop is passing an address to args instead of the number 2.  So I understand why the operand doesn't work.  But it is a complete mystery to me how to get to <code>args</code> as a tuple so I can iterate through.  Can anyone point me in the right direction?</p>