我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用types.ModuleType.__getattribute__()。
def __getattr__(self, name): if name in object_origins: module = __import__(object_origins[name], None, None, [name]) for extra_name in all_by_module[module.__name__]: setattr(self, extra_name, getattr(module, extra_name)) return getattr(module, name) elif name in attribute_modules: __import__('werkzeug.' + name) return ModuleType.__getattribute__(self, name)
def __getattr__(self, name): loader = self._available.get(name) if not loader: return ModuleType.__getattribute__(self, name) self.__dict__[name] = loader() return self.__dict__[name]