would be nice: import from archive

Just just at xs4all.nl
Sat Aug 28 04:16:39 EDT 2004


In article <m3wtzk4562.fsf at g2ctech.com>, Jorge Godoy <godoy at ieee.org> 
wrote:

> It would be great to have one example with more than one file.
> 
> From the discussion I got curious and tested it here and -- since
> Python's so efficient I wasn't surprised that -- it worked. 
> 
> 
> 
> $ cat test.py
> def test():
>         print "Test from file 1"
> 
> $ cat test2.py
> def test():
>         print "Test from file 2"
> 
> 
> >>> import sys
> >>> sys.path.append('test.zip')
> >>> import test
> >>> import test2
> >>> test.test()
> Test from file 1
> >>> test2.test()
> Test from file 2
> >>>
> 
> 
> I also noticed that there was no '.pyc' created for that import, as is
> usually done for uncompressed modules.  

The zipimport module will never write to the zip archive, so for most 
efficient imports, you have to store .pyc data in there yourself. 
zipimport is mostly meant as a repackaging tool, and typical zip files 
only contain .pyc files.

Just



More information about the Python-list mailing list