importing packages from a zip file

Peter Tillotson none at no.chance
Wed Jun 29 13:59:06 EDT 2005


Hi all,

I was wondering if this is possible. In python v2.3 the import systems
was extended via PEP302 to cope with packages. *.py files in a directory
hierarchy can be imported as modules each level in the directory
hierarchy needs to contain at least an empty __init__.py file.

eg. With the file system

base/
__init__.py
    branch1/
    __init__.py
    myModule.py

I can import myModule as follows

import base.branch1.myModule

At the same time its possible to store modules in a flat zip-file and
import modules with the following.

from myZip.zip import myModule.py

but is there a way to do both at the same time? eg.

from myZip.zip import base.branch1.myModule

I'm interested in this in the development of mobile code for some Grid
applications :-)

thanks in advance

p



More information about the Python-list mailing list