Two Python modules require each other's contents - can that work?

Viewed 53813

I have a Bottle webserver module with the following line:

from foobar.formtools import auto_process_form_insert

And the foobar.formtools module contains this line:

from foobar.webserver import redirect, redirect_back

Of course, both result in the following errors (respectively):

ImportError: cannot import name auto_process_form_insert
ImportError: cannot import name redirect

Is it simply a fact that in Python two modules can't import each other and all module imports must be hierarchical in nature, or am I doing something wrong? Alternatively, is there a workaround short of placing all these nice functions in new modules?

2 Answers
Related