[Python-Dev] New Import Hooks PEP, a first draft (and req. for
PEP #)
James C. Ahlstrom
jim@interet.com
Fri, 27 Dec 2002 10:19:59 -0500
Paul Moore wrote:
> It's an interesting idea, but like others, I think that it's not going
> to work right in practice. The main problem is that you don't explain
> how to implement this version of imp.find_module in terms of the
> importer protocol defined in the hooks PEP.
I am exploring the idea of adding the feature to imp.find/load_module
keeping the existing logic. I am not using the hooks PEP because I
think the hooks PEP is a bad idea.
Anyway, after some thought, I think my idea of a file-like object
is not good. The easiest solution is to add a get_data() to
go with find_module() and load_module(). The function signature
of get_data() (or maybe "get_module()") is the same as that
of load_module(), and the interface is:
file, pathname, desc = imp.find_module(name, path=p, suffix=s)
bytes = imp.get_data(name, file, pathname, desc)
JimA