For finally testing modules and subpackages I made a new folder on my Mac OSX Mavericks. Location of the folder is the Desktop:
packtest
 |-- importtest.py
 |-- thepackage 
      |-- __init__.py
      |-- thesubpackage
           |-- __init__.py
           |-- mary.py
the mary.py contains a variable:
marie="Hello"
and nothing else.
In the importtest.py I want to print it out. I tried different ways of importing, basically the ones stated in this Python: importing a sub‑package or sub‑module thread.
Also I tried to add __all__ = ["mary"] to the __init__.py in the thesubpackage folder.
But all I tried did not work. Any Ideas?
Edit:
When trying the suggested solutions I got these errors:
import thepackage.thesubpackage.mary
print thepackage.thesubpackage.mary.marie
results in:
$ python importtest.py
Traceback (most recent call last):
  File "importtest.py", line 1, in <module>
    import thepackage.thesubpackage.mary
ImportError: No module named thepackage.thesubpackage.mary
When trying:
from thepackage.thesubpackage import mary
print mary.marie
The error is:
$ python importtest.py
Traceback (most recent call last):
  File "importtest.py", line 1, in <module>
    from thepackage.thesubpackage import mary
ImportError: No module named thepackage.thesubpackage
 
     
     
     
     
     
     
     
     
    