I\'m learning Python, and I can\'t figure out how imports in __init__.py
work.
I understand from the Python tutorial that the __init__.py
f
It's an absolute hard-and-fast rule in Python that a name must always be defined or imported within the module where you're using it. Here you never import anything inside test.py - so as the error says, do_something
is not defined.
Even if your package/__init__.py
file was executed (which, as others have pointed out, it isn't), your code still wouldn't work as it is, because the import of do_something
has to be done inside test.py if you want to reference it in that file.