Answers for "getting python class from string"

0

getting python class from string

import importlib

def class_for_name(module_name, class_name):
    # load the module, will raise ImportError if module cannot be loaded
    m = importlib.import_module(module_name)
    # get the class, will raise AttributeError if class cannot be found
    c = getattr(m, class_name)
    return c
Posted by: Guest on October-11-2021

Code answers related to "getting python class from string"

Python Answers by Framework

Browse Popular Code Answers by Language