Skip to content

[3.9] gh-89885: Improve import example in language reference (GH-91523) #91649

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

Merged
merged 1 commit into from
Apr 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Doc/reference/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down