Python To Specify Which Module To Import From If There Are Duplicate Module Names?
Related to: Import a module from a relative path dirA/ A.py B.py dirB/ B.py A.py import B # do blah I want A to import B. How do i specify A to import B from dirB in
Solution 1:
I think what you're asking for is how to load a module directly from a directory.
importimpmoduleB= imp.load_source('moduleB', '/ModuleBPath/B.py')
moduleB.MyClass()
Solution 2:
Solution 3:
You could try such variant:
from ..dirB import B
Post a Comment for "Python To Specify Which Module To Import From If There Are Duplicate Module Names?"