Skip to content

Commit 3537d89

Browse files
gh-89885: Improve import example in language reference (GH-91523) (#91649)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit d5a6957) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
1 parent c6c9823 commit 3537d89

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Doc/reference/import.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -483,21 +483,19 @@ submodule. Let's say you have the following directory structure::
483483
spam/
484484
__init__.py
485485
foo.py
486-
bar.py
487486

488-
and ``spam/__init__.py`` has the following lines in it::
487+
and ``spam/__init__.py`` has the following line in it::
489488

490489
from .foo import Foo
491-
from .bar import Bar
492490

493-
then executing the following puts a name binding to ``foo`` and ``bar`` in the
491+
then executing the following puts name bindings for ``foo`` and ``Foo`` in the
494492
``spam`` module::
495493

496494
>>> import spam
497495
>>> spam.foo
498496
<module 'spam.foo' from '/tmp/imports/spam/foo.py'>
499-
>>> spam.bar
500-
<module 'spam.bar' from '/tmp/imports/spam/bar.py'>
497+
>>> spam.Foo
498+
<class 'spam.foo.Foo'>
501499

502500
Given Python's familiar name binding rules this might seem surprising, but
503501
it's actually a fundamental feature of the import system. The invariant

0 commit comments

Comments
 (0)