[MERGE] Support for lazy registation of commands

Alexander Belchenko bialix at ukr.net
Sun Aug 24 09:50:43 BST 2008


+class LazyCommandProxy(object):
+
+    def __init__(self, module, name, aliases):
+        self._module = module
+        self._name = name
+        self.aliases = aliases
+        self.__name__ = name
+
+    def __call__(self, *args, **kwargs):
+        cmd_module = __import__(self._module, globals(), locals(), [True])
+        cmd_class = getattr(cmd_module, self._name)
+        return cmd_class(*args, **kwargs)


Why for you pass [True] as last argument to __import__? IMO, you don't need
to pass there anything. According to Python documentation 4th argument
lists the names that should be imported from module. So importing name
'True' is useless IIUC.

bb:tweak




More information about the bazaar mailing list