Kartic wrote:

Hi Torsten,

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>>> sys.path.append('/location/to/zippedmodules.zip')
py>>> import testzip
py>>> testzip.__file__
'/location/to/zippedmodules.zip/testzip,py'

To generally do it, you have to:
1. Create a class that provides a load_module method that returns a
module type.
2.  Install your class as a hook using
sys.path_hooks.append(your_importer_class)

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
this section.

Is this is what you are looking for?

Thanks,
--Kartic
PS: This about how much I know...the more I find out, I will share :-)

I will just chime in to say I too am looking for information in this area. I hope to put some sort of BoF or Open Space event together for people wishing to learn about (and teach about) the import system from PEP 302 at PyCon this year.

Early bird registration rates are still available today and tomorrow!

regards
 Steve

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to