The problem is submodules are not automatically imported. You have to explicitly import the api
module:
import myproject.mymodule.api
print myproject.mymodule.api.MyClass
If you really insist on api
being available when importing myproject.mymodule
you can put this in myproject/mymodule/__init__.py
:
import myproject.mymodule.api
Then this will work as expected:
from myproject import mymodule
print mymodule.api.MyClass