Mercurial > hg
changeset 2310:d01eac5968c6
demandload: implement __call__
demandload can now load functions and classes, and not just modules.
(So if you access foo() rather than just foo.* it still works).
demandload still doesn't work for constants.
author | John Arbash Meinel <john@arbash-meinel.com> |
---|---|
date | Thu, 18 May 2006 13:52:55 -0700 |
parents | b2f37c7026ca |
children | 4f04368423ec |
files | mercurial/demandload.py |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/demandload.py Thu May 18 13:48:12 2006 -0700 +++ b/mercurial/demandload.py Thu May 18 13:52:55 2006 -0700 @@ -81,6 +81,10 @@ return getattr(importer.module(), target) + def __call__(self, *args, **kwargs): + target = object.__getattribute__(self, 'module')() + return target(*args, **kwargs) + def demandload(scope, modules): '''import modules into scope when each is first used.