Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-133829: Update zipimport example to not be from Python 2 #133835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
Loading
from
21 changes: 12 additions & 9 deletions 21 Doc/library/zipimport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,20 @@ Here is an example that imports a module from a ZIP archive - note that the

.. code-block:: shell-session

$ unzip -l example.zip
sobolevn marked this conversation as resolved.
Show resolved Hide resolved
Archive: example.zip
$ unzip -l example_archive.zip
sobolevn marked this conversation as resolved.
Show resolved Hide resolved
Archive: example_archive.zip
Length Date Time Name
-------- ---- ---- ----
8467 11-26-02 22:30 jwzthreading.py
8467 05-11-25 12:29 example.py
sharktide marked this conversation as resolved.
Show resolved Hide resolved
-------- -------
8467 1 file
$ ./python
Python 2.3 (#1, Aug 1 2003, 19:54:32)

.. code-block:: pycon

>>> import sys
>>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path
>>> import jwzthreading
>>> jwzthreading.__file__
'example.zip/jwzthreading.py'
>>> # Add the archive to the front of the module search path
>>> sys.path.insert(0, 'example_archive.zip')
>>> import example
>>> example.__file__
'example_archive.zip/example.py'

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.