[Python-Dev] An import hook which does nothing
noamr at myrealbox.com
Fri Dec 3 01:55:28 CET 2004
I'm currently writing an import hook which will cache information on the
local disk, instead of retrieving it every time from the slow NFS where
To make sure that I understand how import hooks work, and as a starting
point, I wrote a dummy import hook, which is supposed to behave like the
python's built-in import mechanism.
I post it here, for two reasons:
1. So that developers who understand the import mechanism better than I
do may review it and find things which I didn't do exactly right.
2. Because I think other people might find it helpful when writing new
import hooks, as a starting point as well as for better understanding --
there's nothing like a working example to help you settle up on what
does which where. (Although perhaps a few more comments, in addition to
those which I wrote, might help...)
(Note: I wrote the "DEBUG" parts in order to make sure that my importer
works, because if it fails things might be done by the built-in importer
and I won't notice. These parts can be removed, of course.)
Do you think that it might be useful? Maybe something like that can go
into the "examples" section of the imp module?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1910 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20041203/378063b9/importer.py
More information about the Python-Dev