Python Library Reference
Previous: Up: 29.2 zipimport Next:

29.2.2 Examples

Here is an example that imports a module from a ZIP archive - note that the zipimport module is not explicitly used.

$ unzip -l /tmp/example.zip
Archive: /tmp/example.zip
 Length Date Time Name
 -------- ---- ---- ----
 8467 11-26-02 22:30 jwzthreading.py
 -------- -------
 8467 1 file
$ ./python
Python 2.3 (#1, Aug 1 2003, 19:54:32) 
>>> import sys
>>> sys.path.insert(0, '/tmp/example.zip') # Add .zip file to front of path
>>> import jwzthreading
>>> jwzthreading.__file__
'/tmp/example.zip/jwzthreading.py'

Python Library Reference
Previous: Up: 29.2 zipimport Next:

Release 2.5, documentation updated on 19th September, 2006.
See About this document... for information on suggesting changes.

AltStyle によって変換されたページ (->オリジナル) /