Reputation: 1549
I must be missing something simple here.
I have a directory structure:
maths/
__init__.py
test.py
...
foo/
__init__.py
...
bar/
__init__.py
...
In multiple files (but not all) I am using the path of the module - on Ubuntu for example - that path is /home/nebffa/Desktop/maths
for some tasks. However, I have to compute the path of the maths
package in all of those files - so I thought maybe it will be easier to just have it available via __init__.py
. At least that's what I thought I could do based on reading up on __init__.py
- maybe I'm wrong?
Anyway, attempts to make things available by putting them in the base __init__.py
have failed to work so I think I might be misunderstanding this Python concept.
Upvotes: 1
Views: 99
Reputation: 799390
maths
and maths.test
are two separate modules, each with their own distinct namespace. You will need to explicitly import itertools
in maths.test
if you want it available there.
Also, python -m maths.test
.
Upvotes: 1