How to avoid mutual imports

Brian Quinlan brian at sweetapp.com
Fri Apr 12 14:59:56 EDT 2002


Huaiyu wrote:
> I need advice on how to handle the following situation:

[long description snipped]

If interface.py only defines data_initialization, then you could move
your imports into it i.e.

def data_initialization(...):
 	from utils1 import a, b, c
 	from utils2 import x, y, z

	# do real work

You could also move data_initialization into its own module (might be a
good idea anyway).

Cheers,
Brian






More information about the Python-list mailing list