I have a Python package called simply a "package". In it, I have an empty __init__.py and two modules. One is called m1.py and contains only one line:
x = 3
Another is called m2.py and contains the following line:
x = 5
Now I am trying to use these modules. At first I do something like this:
from package.m1 import x print package.m1.x
Of course, this will not work - I get this error:
NameError: name 'package' is not defined
And I understand why this is not working. But then I do something like this:
from package.m1 import x import package.m2 print package.m1.x
And now it works. What for? How? I did not import package.m1!
source share