Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import plugins as db #195

Open
alabarga opened this issue Sep 4, 2023 · 0 comments
Open

import plugins as db #195

alabarga opened this issue Sep 4, 2023 · 0 comments

Comments

@alabarga
Copy link
Collaborator

alabarga commented Sep 4, 2023

import different backends with same alias

https://stackoverflow.com/questions/72106437/dynamically-assigning-module-names-as-aliases

import importlib
module_names = [('math',), ('numpy','np')]

def Importer(m_name):
    module = importlib.import_module(m_name[0])
    if len(m_name) > 1:
        globals()[x[1]] = module

for x in module_names:
    Importer(x)
names = getattr(foo, '__all__', [])
if not names:
  names = [n for n in foo.__dict__.keys() if n[:1] != '_']

for name in names:
  globals()[name] = getattr(foo, name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant