I have a project that I'd like to restructure to use Python's native implicit namespacing. I have code that I'd like to interface with like this:
from mypackage import Foo
from mypackage.admin import Bar
The admin
sub-package is in a completely separate repository. The files are organized like this:
mypackage
│
└─ core
│ __init__.py
│ file.py
│ foo (contains class 'Foo')
│ ...
And similarly the subpackage:
mypackage
│
└─ admin
│ __init__.py
│ bar.py (contains class Bar)
│ another_folder
│ ...
I had to place everything in my original package into a top level core
subpackage to make the shared namespace work:
from mypackage.core import Foo
from mypackage.admin import Bar
Is there a way I can structure this so I can access everything in my core
package at the top level, as below?
from mypackage import Foo
from mypackage.admin import Bar
I'm import
-ing things as appropriate in the __init__.py
files, but I don't know how to pull objects into the top-level namespace (if it's even supported).
Thanks to this question which is nearly a duplicate, it turns out this isn't possible when using namespaces.