[Python-Dev] New Import Hooks PEP, a first draft (and req. for PEP #)
Thomas Heller
theller@python.net
20 Dec 2002 20:05:09 +0100
> > I suggest we keep imp.find_module but add another argument:
> >
> > find_module(name [, path [, suffixes]])
> >
> > where suffixes defaults to imp.get_suffixes(). This enables it
> > to be used to search for files with different suffixes, for
> > example suffixes=[".conf"].
>
> I'm not sure if I like this: imp.find_module() is designed for finding
> modules, not arbitrary files. It's an interesting idea though, but this
> would neccesarily complicate the importer protocol, as each importer
> would have to deal with arbitrary suffixes. It implies file-system
> semantics that importer objects can't neccesarily satisfy, eg. an
> importer doesn't neccesarily deal with suffixes at *all*.
I also found this an interesting idea, first.
But then, how would this (working) code have to be written with the
new imp.find_module() function:
def get_exe_bytes (self):
# wininst.exe is in the same directory as this file
directory = os.path.dirname(__file__)
filename = os.path.join(directory, "wininst.exe")
return open(filename, "rb").read()
Thomas