From 842443e52b42f75ae880beb31357bae1603782d8 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sat, 10 May 2025 10:31:12 -0400 Subject: [PATCH 01/12] gh-133829 Update zipimport example to use pip.pyz --- Doc/library/zipimport.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index cd76f29a556939..d4f66cb27a9fc7 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -188,17 +188,18 @@ Here is an example that imports a module from a ZIP archive - note that the .. code-block:: shell-session - $ unzip -l example.zip - Archive: example.zip + $ unzip -l pip.pyz + Archive: pip.pyz Length Date Time Name -------- ---- ---- ---- - 8467 11-26-02 22:30 jwzthreading.py + 32145 05-10-25 10:00 pip/__main__.py -------- ------- - 8467 1 file + 32145 1 file $ ./python - Python 2.3 (#1, Aug 1 2003, 19:54:32) + Python 3.x >>> import sys - >>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path - >>> import jwzthreading - >>> jwzthreading.__file__ - 'example.zip/jwzthreading.py' + >>> sys.path.insert(0, 'pip.pyz') # Add .pyz file to front of path + >>> import pip + >>> pip.__file__ + 'pip.pyz/pip/__main__.py' + From 38d41add0a96682250b69351717c38500e1d3929 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sat, 10 May 2025 15:01:56 -0400 Subject: [PATCH 02/12] gh-133829 Under request, break up example into 2 code blocks --- Doc/library/zipimport.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index d4f66cb27a9fc7..4104d4ac7ee281 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -195,8 +195,12 @@ Here is an example that imports a module from a ZIP archive - note that the 32145 05-10-25 10:00 pip/__main__.py -------- ------- 32145 1 file + +Now for the Python: + +.. code-block:: python + $ ./python - Python 3.x >>> import sys >>> sys.path.insert(0, 'pip.pyz') # Add .pyz file to front of path >>> import pip From 93da900d1fc604f432340071800c519dcedd4c85 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sat, 10 May 2025 15:06:55 -0400 Subject: [PATCH 03/12] gh-133829 remove $ ./python marker in python codeblock --- Doc/library/zipimport.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index 4104d4ac7ee281..b0ffedf9786715 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -200,7 +200,6 @@ Now for the Python: .. code-block:: python - $ ./python >>> import sys >>> sys.path.insert(0, 'pip.pyz') # Add .pyz file to front of path >>> import pip From 72ff028324d3b241cb291d620beddff1281d803e Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sat, 10 May 2025 18:51:58 -0400 Subject: [PATCH 04/12] agh-130829 simplify example --- Doc/library/zipimport.rst | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index b0ffedf9786715..ac7cbe9d73bc7e 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -186,18 +186,6 @@ Examples Here is an example that imports a module from a ZIP archive - note that the :mod:`zipimport` module is not explicitly used. -.. code-block:: shell-session - - $ unzip -l pip.pyz - Archive: pip.pyz - Length Date Time Name - -------- ---- ---- ---- - 32145 05-10-25 10:00 pip/__main__.py - -------- ------- - 32145 1 file - -Now for the Python: - .. code-block:: python >>> import sys From 0b5e2a5716fb6100231436c0cb00a0db896c8fa7 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sun, 11 May 2025 09:04:11 -0400 Subject: [PATCH 05/12] gh-133829 Update example to use ``example.zip`` ``example.py`` and ``import example`` --- Doc/library/zipimport.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index ac7cbe9d73bc7e..b87251115a11ed 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -189,8 +189,8 @@ Here is an example that imports a module from a ZIP archive - note that the .. code-block:: python >>> import sys - >>> sys.path.insert(0, 'pip.pyz') # Add .pyz file to front of path - >>> import pip - >>> pip.__file__ - 'pip.pyz/pip/__main__.py' + >>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path + >>> import example + >>> example.__file__ + 'example.zip/example/__main__.py' From 24788ebd4ef95afe31a8c1f4e120e1147fedd3a9 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sun, 11 May 2025 12:31:50 -0400 Subject: [PATCH 06/12] gh-133829 Clarify filename of zip to ``example_archive.zip`` --- Doc/library/zipimport.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index b87251115a11ed..5beeb23cf64626 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -186,11 +186,20 @@ Examples Here is an example that imports a module from a ZIP archive - note that the :mod:`zipimport` module is not explicitly used. +.. code-block:: shell-session + $ unzip -l example_archive.zip + Archive: example.zip + Length Date Time Name + -------- ---- ---- ---- + 8467 05-11-25 12:29 example.py + -------- ------- + 8467 1 file + .. code-block:: python >>> import sys - >>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path + >>> sys.path.insert(0, 'example_archive.zip') # Add .zip file to front of path >>> import example >>> example.__file__ - 'example.zip/example/__main__.py' + 'example.zip/example.py' From b8eccf7ecd3b1681e36e7697ab7db6bdf21b80fe Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sun, 11 May 2025 12:37:51 -0400 Subject: [PATCH 07/12] Update zipimport.rst --- Doc/library/zipimport.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index 5beeb23cf64626..2af9e1e697ac91 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -188,7 +188,7 @@ Here is an example that imports a module from a ZIP archive - note that the .. code-block:: shell-session $ unzip -l example_archive.zip - Archive: example.zip + Archive: example_archive.zip Length Date Time Name -------- ---- ---- ---- 8467 05-11-25 12:29 example.py @@ -201,5 +201,5 @@ Here is an example that imports a module from a ZIP archive - note that the >>> sys.path.insert(0, 'example_archive.zip') # Add .zip file to front of path >>> import example >>> example.__file__ - 'example.zip/example.py' + 'example_archive.zip/example.py' From e7c93b9dfe1f30373854fff72a70a94ed4ea774e Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sun, 11 May 2025 12:47:58 -0400 Subject: [PATCH 08/12] Fix test fails --- Doc/library/zipimport.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index 2af9e1e697ac91..f261e82145a768 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -187,6 +187,7 @@ Here is an example that imports a module from a ZIP archive - note that the :mod:`zipimport` module is not explicitly used. .. code-block:: shell-session + $ unzip -l example_archive.zip Archive: example_archive.zip Length Date Time Name From b224d43a94440e4c5d285c5b7bbc40fc56f81884 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 11 May 2025 19:53:51 +0300 Subject: [PATCH 09/12] Update Doc/library/zipimport.rst --- Doc/library/zipimport.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index f261e82145a768..18558b1371e22d 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -188,6 +188,7 @@ Here is an example that imports a module from a ZIP archive - note that the .. code-block:: shell-session + $ unzip -l example_archive.zip Archive: example_archive.zip Length Date Time Name From cff42fad16f2884e95f3db8198cfe6fa45f780d4 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 11 May 2025 19:54:53 +0300 Subject: [PATCH 10/12] Update Doc/library/zipimport.rst --- Doc/library/zipimport.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index 18558b1371e22d..01419fd7716cce 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -197,7 +197,7 @@ Here is an example that imports a module from a ZIP archive - note that the -------- ------- 8467 1 file -.. code-block:: python +.. code-block:: pycon >>> import sys >>> sys.path.insert(0, 'example_archive.zip') # Add .zip file to front of path From dc210017d052dde1b89368d47fc934247acd2b04 Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sun, 11 May 2025 15:02:29 -0400 Subject: [PATCH 11/12] Update Doc/library/zipimport.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/library/zipimport.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index 01419fd7716cce..5d00e7b8bcc5a1 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -188,7 +188,6 @@ Here is an example that imports a module from a ZIP archive - note that the .. code-block:: shell-session - $ unzip -l example_archive.zip Archive: example_archive.zip Length Date Time Name From 548857f14a85dd944b941b21bd3b5d3a2514d03a Mon Sep 17 00:00:00 2001 From: Rihaan Meher Date: Sun, 18 May 2025 13:03:45 -0400 Subject: [PATCH 12/12] Update Doc/library/zipimport.rst Co-authored-by: Peter Bierma --- Doc/library/zipimport.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index 5d00e7b8bcc5a1..62efdf59947951 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -199,7 +199,8 @@ Here is an example that imports a module from a ZIP archive - note that the .. code-block:: pycon >>> import sys - >>> sys.path.insert(0, 'example_archive.zip') # Add .zip file to front of path + >>> # 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' pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy