Python : importing different module with same name

后端 未结 1 1986
执念已碎
执念已碎 2021-01-19 12:34

I am working on a project that requires to have several modules with the same name. This is a representative extract of the architecture, with __init__.py files

相关标签:
1条回答
  • 2021-01-19 13:30

    One way would be to use the imp module.

    import imp
    somectrl = imp.load_source("somectrl", "path1/ProjectA/src/ctrl/somectrl.py")
    someclass = imp.load_source("someclass", "path2/ProjectA/src/someclass.py")
    
    0 讨论(0)
提交回复
热议问题