diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-04-17 21:51:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-17 21:51:19 (GMT) |
commit | 3537d897e069be9c7bde9a50b205f275791ffdbe (patch) | |
tree | 2f793aa2009c302e366ccee834ffb752ef1f1b7e /Doc/reference | |
parent | c6c98234552ba0ddc696c17d27eb48cc89d20abf (diff) | |
download | cpython-3537d897e069be9c7bde9a50b205f275791ffdbe.zip cpython-3537d897e069be9c7bde9a50b205f275791ffdbe.tar.gz cpython-3537d897e069be9c7bde9a50b205f275791ffdbe.tar.bz2 |
gh-89885: Improve import example in language reference (GH-91523) (#91649)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit d5a69571f586080af4c29671c47f9c4bc671af7f)
Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/import.rst | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index 2c84a97..2d9802b 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -483,21 +483,19 @@ 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:: +and ``spam/__init__.py`` has the following line in it:: from .foo import Foo - from .bar import Bar -then executing the following puts a name binding to ``foo`` and ``bar`` in the +then executing the following puts name bindings for ``foo`` and ``Foo`` in the ``spam`` module:: >>> import spam >>> spam.foo <module 'spam.foo' from '/tmp/imports/spam/foo.py'> - >>> spam.bar - <module 'spam.bar' from '/tmp/imports/spam/bar.py'> + >>> spam.Foo + <class 'spam.foo.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 |