Coping with cyclic imports
Jeffrey Froman
jeffrey at fro.man
Tue Apr 8 16:41:06 EDT 2008
Torsten Bronger wrote:
> I know that cyclic imports work in Python under certain
> circumstances. Can anyone refer me to a page which explains when
> this works?
I don't know of a specific URL offhand.
Cyclic imports are not a problem by themselves, but cyclic definitions are.
Thus:
# a.py
import b
x = 1
# b.py
import a
x = 2
works fine, but:
# a.py
import b
x = 1
# b.py
import a
x = a.x + 1 # circular definition
does not.
Jeffrey
More information about the Python-list
mailing list