From 9ec1c1c1ad1cdd2881bce6ae83c7d8d7cfc2a7ed Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Wed, 13 Apr 2022 23:22:52 -0700 Subject: [PATCH 1/4] Add example for spam.Bar --- Doc/reference/import.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index 66737c698ae90d..db2a0c328ed68b 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -497,14 +497,16 @@ and ``spam/__init__.py`` has the following lines in it:: from .foo import Foo from .bar import Bar -then executing the following puts a name binding to ``foo`` and ``bar`` in the -``spam`` module:: +then executing the following puts a name binding to ``foo`` and ``bar`` (as well +as ``Foo`` and ``Bar``) in the ``spam`` module:: >>> import spam >>> spam.foo - >>> spam.bar - + >>> spam.Bar + + + Given Python's familiar name binding rules this might seem surprising, but it's actually a fundamental feature of the import system. The invariant From 0190cb9957cf5b349b158a5760d9a3561f34ea65 Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Sat, 16 Apr 2022 00:14:03 -0700 Subject: [PATCH 2/4] Removed Bar for simpler example --- Doc/reference/import.rst | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index db2a0c328ed68b..936f259cebc0af 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -490,21 +490,18 @@ submodule. Let's say you have the following directory structure:: spam/ __init__.py foo.py - bar.py and ``spam/__init__.py`` has the following lines in it:: from .foo import Foo - from .bar import Bar -then executing the following puts a name binding to ``foo`` and ``bar`` (as well -as ``Foo`` and ``Bar``) in the ``spam`` module:: +then executing the following puts a name binding to ``foo`` and ``Foo`` in the ``spam`` module:: >>> import spam >>> spam.foo - >>> spam.Bar - + >>> spam.Foo + From 6b1916832d669eb69205fd73d37ec652dafec5aa Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Sat, 16 Apr 2022 00:16:16 -0700 Subject: [PATCH 3/4] Wrap line --- Doc/reference/import.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index 936f259cebc0af..26bdda619ad6cc 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -495,7 +495,8 @@ and ``spam/__init__.py`` has the following lines in it:: from .foo import Foo -then executing the following puts a name binding to ``foo`` and ``Foo`` in the ``spam`` module:: +then executing the following puts a name binding to ``foo`` and ``Foo`` in the +``spam`` module:: >>> import spam >>> spam.foo From 566c8b3c9defe634583e35a95653a31ad6d7e9af Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:13:28 -0700 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Jelle Zijlstra --- Doc/reference/import.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index 26bdda619ad6cc..988d41c81c6ab6 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -491,11 +491,11 @@ submodule. Let's say you have the following directory structure:: __init__.py foo.py -and ``spam/__init__.py`` has the following lines in it:: +and ``spam/__init__.py`` has the following line in it:: from .foo import Foo -then executing the following puts a name binding to ``foo`` and ``Foo`` in the +then executing the following puts name bindings for ``foo`` and ``Foo`` in the ``spam`` module:: >>> import spam @@ -504,8 +504,6 @@ then executing the following puts a name binding to ``foo`` and ``Foo`` in the >>> spam.Foo - - Given Python's familiar name binding rules this might seem surprising, but it's actually a fundamental feature of the import system. The invariant holding is that if you have ``sys.modules['spam']`` and