In my working python directory I create:
packagename/__init__.py
packagename/modulename.py
test.py
In modulename.py I create some empty class:
class Someclass(object):
pass
in test.py:
import packagename
packagename.modulename.Someclass()
Why I can't call packagename.modulename.someclass() in test.py ?
AttributeError: 'module' object has no attribute 'modulename'
I understand that the right way is:
import packagename.modulename
or
from packagename import modulename
But I do not understand why I get this error in my case.
Update:
In other words is there any way to import a package's content with all modules in the distinct namespace? I need correct pythonic expression for:
from packagename import * as mynamespace