Changeset 391 for python/trunk/Doc/library/zipimport.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/zipimport.rst
r2 r391 13 13 :file:`\*.py[co]`) and packages from ZIP-format archives. It is usually not 14 14 needed to use the :mod:`zipimport` module explicitly; it is automatically used 15 by the built-in :keyword:`import` mechanism for ``sys.path`` items that are paths15 by the built-in :keyword:`import` mechanism for :data:`sys.path` items that are paths 16 16 to ZIP archives. 17 17 18 Typically, ``sys.path`` is a list of directory names as strings. This module19 also allows an item of ``sys.path`` to be a string naming a ZIP file archive.18 Typically, :data:`sys.path` is a list of directory names as strings. This module 19 also allows an item of :data:`sys.path` to be a string naming a ZIP file archive. 20 20 The ZIP archive can contain a subdirectory structure to support package imports, 21 21 and a path within the archive can be specified to only import from a 22 subdirectory. For example, the path :file:` /tmp/example.zip/lib/` would only22 subdirectory. For example, the path :file:`example.zip/lib/` would only 23 23 import from the :file:`lib/` subdirectory within the archive. 24 24 … … 34 34 since this would imply that the ZIP has been altered during runtime. 35 35 36 ZIP archives with an archive comment are currently not supported. 37 36 38 .. seealso:: 37 39 … … 40 42 algorithms used. 41 43 42 :pep:` 0273` - Import Modules from Zip Archives44 :pep:`273` - Import Modules from Zip Archives 43 45 Written by James C. Ahlstrom, who also provided an implementation. Python 2.3 44 46 follows the specification in PEP 273, but uses an implementation written by Just 45 47 van Rossum that uses the import hooks described in PEP 302. 46 48 47 :pep:` 0302` - New Import Hooks49 :pep:`302` - New Import Hooks 48 50 The PEP to add the import hooks that help this module work. 49 51 … … 95 97 96 98 99 .. method:: get_filename(fullname) 100 101 Return the value ``__file__`` would be set to if the specified module 102 was imported. Raise :exc:`ZipImportError` if the module couldn't be 103 found. 104 105 .. versionadded:: 2.7 106 107 97 108 .. method:: get_source(fullname) 98 109 … … 141 152 :mod:`zipimport` module is not explicitly used. :: 142 153 143 $ unzip -l /tmp/example.zip144 Archive: /tmp/example.zip154 $ unzip -l example.zip 155 Archive: example.zip 145 156 Length Date Time Name 146 157 -------- ---- ---- ---- … … 151 162 Python 2.3 (#1, Aug 1 2003, 19:54:32) 152 163 >>> import sys 153 >>> sys.path.insert(0, ' /tmp/example.zip') # Add .zip file to front of path164 >>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path 154 165 >>> import jwzthreading 155 166 >>> jwzthreading.__file__ 156 ' /tmp/example.zip/jwzthreading.py'167 'example.zip/jwzthreading.py' 157 168
Note:
See TracChangeset
for help on using the changeset viewer.