You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggestion for disambiguation re import expectations and __init__.py #1929
Having just gone through the tutorial, I found myself confused because once the project is packaged and installed, and then imported, the add_one() function seemed unavailable.
"import example_package" was without error, but attempting to use example_package.add_one(3) gave AttributeError: module 'example_package' has no attribute 'add_one'
"from example_package import add_one" gives ImportError: cannot import name 'add_one' from 'example_package'
"from example_package import *" runs without error, but then attempting to use add_one gives NameError: name 'add_one' is not defined
The only way I have been able to run "add_one()" has been as
"from example_package.example import add_one".
While this is understandable as the function is defined in the top level example.py file, it definitely violated my expectations as almost every package I use would allow me to use "import example_package" and then "example_package.add_one()" or "from example_package import add_one" and then run "add_one()"
I am suggesting either an example of loading the package and using the function, or the addition of modifying the init.py to add "from .example import add_one"
Code of Conduct
I am aware that participants in this repository must follow the PSF Code of Conduct.
This still looks actionable as a small tutorial docs change: add a "Using your newly installed package" heading after installing from TestPyPI/PyPI and make the existing import example easier to find.
Activity
ncoghlan commentedon Oct 10, 2025
There is a short usage example at the end of https://packaging.python.org/en/latest/tutorials/packaging-projects/#installing-your-newly-uploaded-package, but that could perhaps be made clearer with a dedicated "Using your newly installed package" heading.
Herrtian commentedon May 22, 2026
This still looks actionable as a small tutorial docs change: add a "Using your newly installed package" heading after installing from TestPyPI/PyPI and make the existing import example easier to find.