i noticed some seemingly strange behaviour when trying to import a python module named rmod2 in different ways. if i start python from the directory where the rmod2.py file is located, it works fine. however, if i move the file to another folder where other modules are locate, it doesn't work as expected anymore. the module/package folder is /usr/lib/pymodules/python2.7 and it is also contained in the sys.path. so i've created the folder /usr/lib/pymodules/python2.7/rmod2 and put an empty __init__.py and the rmod2.py in there. if i don't have the __init__.py i get:
>>> import rmod2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named rmod2
with the __init__.py file, the import seems to work, but the package is empty:
>>> import rmod2
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'rmod2']
>>> dir(rmod2)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
>>> rmod2.__path__
['/usr/lib/pymodules/python2.7/rmod2']
>>> rmod2.__file__
'/usr/lib/pymodules/python2.7/rmod2/__init__.py'
can someone tell me what's going on, and how to fix it to actually load the module contents when importing?