Python -Passing a class method as the default value of an argument to another class initialization
<p>Modifying the original question to prevent confusions. I have 2 classes defined in 2 different modules:</p>

<pre><code>class Heuristic:
    def process(self,data,x,y):
        processed_data = (data + x) /y 
        return processed_data

class GTS(Abstract_Strat):
    def __init__(self, data, method= Heuristic().process(),*args):
        self.data= data
        self.method = method
        self.func_args = args
</code></pre>

<p>So in the class GTS, in the initialization function, I am trying to pass a method that belongs to class heuristic which is in another module. On trying this, I get the following error:</p>

<pre><code>TypeError: process() takes exactly 3 arguments (1 given)
</code></pre>

<p>I searched stackoverflow and found similar questions where the <code>Typerror</code> referred to the <code>_init_</code> method. But in this case, the error is for a function passed in as argument to the <code>_init_</code> method. So the question is- What is the right way to pass a method of one class as a default argument value to to intializer of another class?</p>

<p>In python, you must construct an instance of the class before you can have access to an object and then subsequently it's methods.</p>

<p>You might do something like:</p>

<pre><code>class GTS(Abstract_Strat):
    heuristic = Heuristic(data)
    def __init__(self, data, method= heuristic.process(),*args):
        self.data= data
        self.method = method
        self.func_args = args
</code></pre>

<p>Thereby constructing your object and giving you access to its "bound" methods.  The first parameter it is referring to is the "self" in the definition, to which you do not have access until it is an instance of the class has been initialized.</p>

python class methods parameter-passing typeerror