This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: documentation missing information on objects in submodules
Type: enhancement Stage:
Components: Documentation Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, rapp.jens, terry.reedy
Priority: normal Keywords:

Created on 2021-11-05 07:32 by rapp.jens, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg405769 - (view) Author: Jens Rapp (rapp.jens) Date: 2021-11-05 07:32
Documentation 5.4.2. Submodules tells what happens to modules which are imported inside __init__.py of a package>


from .foo import Foo
from .bar import Bar

then executing the following puts a name binding to foo and bar 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'>

I miss information on what happes to Foo and Bar. 
is it directly usable under spam.Bar() or does one have to use spam.bar.Bar()?

To my mind, that example should tell this.
msg405842 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-11-06 02:13
https://docs.python.org/3/reference/import.html#submodules

The point of the section is that even though the names 'for' and 'bar' are not directly importing into 'spam', they get attached to 'spam' any way as indirect effect of 'from'.  'Foo' and 'Bar are directly imported and so are also bound.  How about 

"Executing the following puts a name binding to foo and bar (as well as Foo and Bar) in the spam module:

>>> spam.Foo
<class spam.foo.Foo>
(This should be checked in case the .foo changes the report.)

I think one example showing both foo and Foo would be enough.
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89885
2021-11-06 02:13:33terry.reedysetnosy: + terry.reedy
messages: + msg405842
2021-11-05 07:32:21rapp.jenscreate