Source code for dnn_reco.misc

from __future__ import division, print_function
import importlib






[docs] def load_class(full_class_string): """ dynamically load a class from a string Parameters ---------- full_class_string : str The full class string to the given python clas. Example: my_project.my_module.my_class Returns ------- python class PYthon class defined by the 'full_class_string' """ class_data = full_class_string.split(".") module_path = ".".join(class_data[:-1]) class_str = class_data[-1] module = importlib.import_module(module_path) # Finally, we retrieve the Class return getattr(module, class_str)