Greg Stein wrote:
get_code() is *NOT* a public method. It is for subclasses to override.
Oh, ok. But that makes it very specific to your implementation. I'd like to see a much more general idea. I'm sure that it's there in your code but it is not very clear...
The "public method" is the _import_hook method, but it isn't really public, as it gets installed into the import hook. However, it wouldn't be hard to add "__call__ = _import_hook" to the Importer class. That would provide the appropriate callable interface.
I see, that makes sense. Then the idea could boil down to something like this: Each element of sys.path is either of these: - a string, in which case the "classic" importer will do the work. - a callable object, which must have the same interface (signature) as the current __import__ hook. (that's basically where you started, right?) Just