Python version: 2.7.12
I created my own module which is called mymodule.py. I put the module inside the mymodule directory, so:
mymodule/
__init__.py
mymodule.py
Additionally I checked the sys.path list and I moved whole mymodule/ to /usr/lib64/python2.7/site-packages/ where the numpy/ catalog is also located. When I run the python I can import mymodule in all these ways:
>>> import mymodule.mymodule
>>> from mymodule import mymodule
>>> from mymodule.mymodule import fun1, var1
I understand the hierarchy of files and catalogs. I know that mymodule/ is level up than mymodule, thus a dot operator is needed. But we can notice similar structure for the numpy/ catalog and in this case:
>>> import numpy
is enough to import this module, not:
>>> import numpy.numpy
I read the official documentation about modules and I can't find the answer. Of course I can put mymodule.py inside /usr/lib64/python2.7/site-packages/ but it could cause a mess. Moreover mymodule/ give me something like a namespace (someone else can create also mymodule.py file containing different statements).
Which way is recommended to publish own modules?