Just add to your __init__.py files:
import importlib
def __getattr__(submodule_name):
return importlib.import_module('.' + submodule_name, __package__)
And then just import the root module and use it without ever needing to import individual submodules:import foo
def bar():
return foo.subfoo.bar() # foo.subfoo is imported when the function is first executed instead of when it is parsed, so no circular import happen