I have a package like this
package/
    __init__.py
    subpackage1/
        __init__.py
        moduleA.py
        moduleB.py
        moduleC.py
        moduleD.py
    subpackage2/
       __init__.py
       moduleX.py
       moduleY.py
       moduleZ.py
In moduleB.py, I am importing
from moduleA import bar
In moduleA, I am importing
from moduleB import foo
I am getting ImportError.
ImportError: cannot import name foo
What could be the problem here ? and to avoid this problem, what should I do ? and what should I write in _init_.py pf package, subpackage1, subpackage2 ?
_init_.py of subpackage1
from moduleA import *
from moduleB import *
from moudleC import *
from moudleD import *
_init_.py of subpackage2
from moduleX import *
from moduleY import *
from moduleZ import *
_init_.py of package
from subpackage1 import *
from subpackage2 import *
Is there some problem with my _init_.py files ?
EDIT: I have changed imports
moduleB
from .moduleA import bar
moduleA
from .moduleB import foo
Still, I am getting the same import error.
ImportError: cannot import name foo
EDIT:
moduleB
def Bar():
    def __init__(self):
        self.foo = Foo()
        self.val = 10
        .
        .
moduleA
def Foo():
    def __init__(self):
        self.bar = Bar()
        self.val = 5
        .
        .   
I want to do this. And I insist on keeping both classes in different files. How should I import ?
 
     
     
    