def importWithReload(moduleName, names): """ Returns specific names from a module, after reloading them. The moduleName argument should be a string. The names argument can either be a list of names (strings), or a single name. """ mod = __import__(moduleName) components = moduleName.split('.') for comp in components[1:]: mod = getattr(mod, comp) mod = reload(mod) if isinstance(names, list): output = [] for name in names: output.append(getattr(mod, name)) return output return getattr(mod, names)