# In b.py:
Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).
(At first glance it might appear that cause_a_to_do_something() would be hugely inefficient because it does an import every time you call it, but in fact the import work only gets done the first time. The second and subsequent times you import a module, it's a quick operation.)
If you really must have mutual imports in Python, the way to do it is to import them within a function:
Interesting; I wonder why the interpreter does not give a proper error message in this case?
Now a.py can safely do import b without causing problems.
Please be aware that this adds over-head when the function is called, as you put the import logic at function call time, rather than program load time.
Thank you! I know for the first time that importing in different places make such a difference.
You have mutual top-level imports, which is almost always a bad idea.