In your Python package, you have:
- an
__init__.py
that designates this as a Python package - a
module_a.py
, containing a functionaction_a()
that references an attribute (like a function or variable) inmodule_b.py
, and - a
module_b.py
, containing a functionaction_b()
that references an attribute (like a function or variable) inmodule_a.py
.
This situation can introduce a circular import error: module_a
attempts to import module_b
, but can't, because module_b
needs to import module_a
, which is in the process of being interpreted.
But, sometimes Python is magic, and code that looks like it should cause this circular import error works just fine!