How to let python function pass more variables than what's accepted in the definition?
<p>I have a very generic function call that looks like</p>

<pre><code>result = getattr(class_name, func_name)(result)
</code></pre>

<p>This function call updates <code>result</code>. This function call is very generic such that it can invoke many functions from different classes. Currently, all these functions only take one argument <code>result</code>. However, it doesn't scale to the cases that some functions need to pass more than just <code>result</code> but more arguments (say, <code>args</code>).</p>

<p>Is there a way in Python (2.7) that allows this generic function call to pass <code>args</code> but still invoke the functions that don't have the extra arguments? If not, what would be a better approach to solve this problem?</p>

<p>EDIT: I cannot change the existing function definitions, including those that only take only the argument <code>result</code>. I can only change this line:</p>

<pre><code>result = getattr(class_name, func_name)(result)
</code></pre>

<p>You can add a <code>*</code> within the function call. This will pass <code>result</code> as multiple arguments. Lets say you have two functions:</p>

<pre><code>class YourClass:
   def my_first_def(one_arg):
      return (1, 2)

   def my_second_def(one_arg, second_arg):
      return (1, 2, 3)


if not instanceof(result, tuple):
  result = (result,)

result = getattr(YourClass, 'my_first_def')(*result)
result = getattr(YourClass, 'my_second_def')(*result)
</code></pre>

<p>Do note that <code>result</code> must be a <code>tuple</code></p>

python python-2.7