I came across some situation like shown below, where each class needs the other class and it creates the cyclic dependency. I came across this type of situation while wrapping some C code using ctypes. There already are lots of post on this topic but I didn't find them helpful, I need some example.
Module A:
from B import C2 class C1(object): def __init__(self): self.name = "C1" self.c2 = C2() Module B
from A import C1 class C2(object): def __init__(self): self.name = "C2" self.c1 = C1() Main
from A import C1 if __name__ == "__main__": o = C1() print(o.name)
__init__()method ofC1unconditionally calls the__init__()ofC2and vice versa.