import hook, overwrite import?
kartic.krishnamurthy at gmail.com
Wed Jan 26 11:16:49 EST 2005
If you want to use other methods to import (other than good ole file
system), yes, you can create an importer class and register it as an
importer module, that import will use to search and import.
For example, it is possible to use zip imports (this functionality is
already builtin) to import from a zip archive.
py>>> import zlib # required
py>>> import sys
py>>> import testzip
To generally do it, you have to:
1. Create a class that provides a load_module method that returns a
2. Install your class as a hook using
Please take a look at the imp module :
http://docs.python.org/lib/module-imp.html for a complete description
on accessing the import internals. There is also a simple example in
Is this is what you are looking for?
PS: This about how much I know...the more I find out, I will share :-)
More information about the Python-list