Nov-06-2019, 01:01 PM
So I've never really sorted out a good solution to this issue, and from what I can see, there really isn't one. so I thought I'd post here as a last ditch effort to settle the issue.
The problem is this:
I am writing a series of python modules which serve as extensions / plugins for an application. The application adds modules located in the user's /Mod directory to it's environment path on startup. However, the application uses the *second* directory in the hierarchy as the top-level name for the package.
So the structure looks like this:
The issue, then, is I have to maintain this structure for the sake of the application, but it forces me to pollute the import statements with extra long names.
Of course, I can't just alias the import, e.g.:
The problem is this:
I am writing a series of python modules which serve as extensions / plugins for an application. The application adds modules located in the user's /Mod directory to it's environment path on startup. However, the application uses the *second* directory in the hierarchy as the top-level name for the package.
So the structure looks like this:
/Mod |--my_extension_first |--my_extension_second |--__init__.py |--my_extension_code.pyAccessing the extension directly from within the application's python console, then, would work by calling:
from my_extension_second import my_extension_codeBut, if I want to access the modules from within another module (say, in another extension), I'd have to use:
from my_extension_first.my_extension_second import my_extension_code
The issue, then, is I have to maintain this structure for the sake of the application, but it forces me to pollute the import statements with extra long names.
Of course, I can't just alias the import, e.g.:
import my_extension_first.my_extension_second my_ext = my_extension_first.my_extension_second from my_ext import my_extension_codeSo is there a way to more cleanly manage something like this? Some other way to alias a package path that I haven't discovered?