I have two modules and each module contains a class. In each module I want to reference methods from the class in the other module. I have setup a small class to help wrap my head around the concept. I imported one module into the other module, but I am still getting a circular import error. To my understanding this is the proper way to do it, but I am still getting an error. Here are my example classes:
a.py module:
import b
class A():
def __init__(self):
print("A has run")
def aa():
print("aa has run")
b.B.bb()
b.py module:
import a
class B():
def __init__(self):
print("B has run")
def bb():
print("bb has run")
# Run method from class in seperate module
a.A.aa()
Here is my error:
AttributeError: partially initialized module 'b' has no attribute 'B' (most likely due to a circular import)