Jim Jewett wrote: > I had thought that wouldn't be run until the module was otherwise > loaded. Are you saying that just creating the callback forces a load > under lazy loading, but not under post-load hooks?
The imp.imported (or whatever we name the method) is the register method for the post import hook system. It's not connected to lazy imports directly. Internally lazy imports and post import hooks work together but that's an implementation detail. I was saying that the problem can't be solved with lazy imports. Here is an example in doc test style how lazy imports and post import hooks would work together: Register a hook >>> def hook(mod): ... print "Module loaded" >>> imp.register_post_import_hook(hook, "decimal") Load the decimal module lazy. >>> decimal = imp.importlazy("decimal") decimal is a lazy module. Any attribute access will load the real decimal module. >>> imp.islazy(decimal) True Registering the decimal.Decimal class with the Inexact ABC loads the real decimal module. >>> Inexact.register(decimal.Decimal) Module loaded >>> imp.islazy(decimal) False Christian _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com