import importlib


def dynamicImport(fullName):
    """
    This function returns the requested attribute of a module; it manages the necessary imports.
    The input argument is the full name as a string, e.g. 'module.package.method'.
    Alternatively, the input argument may be a list of such full names. The output will then be a list of same size containing the requested attributes in the same order.
    This only works for modern Python (at least Python > 3).
    """
    if fullName is None:  # safety
        return None
    elif fullName is list or fullName is tuple:
        requested_attributes = []
        for name in fullName:
            requested_attributes.append(dynamicImport(name))
        return requested_attributes
    else:
        split_name = fullName.split(".")
        module_name = ".".join(split_name[0:-1])
        attribute_name = split_name[-1]
        module = importlib.import_module(module_name)
        requested_attribute = getattr(module, attribute_name)
        return requested_attribute