标签:
class LazyImport: def __init__(self,module_name): self.module_name = module_name self.module = None def __getattr__(self,name): if self.module is None: self.module = __import__(self.module_name) return getattr(self.module,name) string = LazyImport("string") print string.lowercase
标签:
原文地址:http://www.cnblogs.com/olivetree123/p/4857034.html