The methods, which are used for debugging, rely on some class attributes. So in the original version, they are written as private class methods in each class. The code is repeated.
class Network1(NetworkTemplate):
def __init__(self, model_config)
self.parameter = model_config
def __debug_tool(self):
# repeated code
return self.parameter
class Network2(NetworkTemplate):
def __init__(self, model_config)
self.parameter = model_config
def __debug_tool(self):
# repeated code
return self.parameter
I am wondering how I could reuse the repeated code.
I thought of import __debug_tool
but it depends on some class attributes self.parameter
. I don't know if I should manually pass 6 parameters to the imported function, because it looks ugly.
Writing it in the NetworkTemplate
as a public method seems the right thing to do, but I am not sure if it will impact the normal performance (i.e. with the debug tools turned off, or committed out, in the Network1
).