Suppose I have the following loader method:
#################################
# Load a class
#################################
def __load_class(self, module_name, class_name, params):
try:
loaded_class = getattr(importlib.import_module(module_name), class_name)
obj = loaded_class(params)
return obj
except Exception as ex:
self.logger.error("FAILED to load class: {0}.{1}\n{2}".format(module_name, class_name, traceback.format_exc()))
How do I pass the params
needed to instantiate my class to this method? I have classes that take 1 parameter and others that take 2 parameters.
NOTE: I have no control of the classes I am trying to instantiate. I can't change their arguments.