How to avoid mutual imports
Tom Good
Tom_Good1 at excite.com
Fri Apr 12 18:03:34 EDT 2002
huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) wrote in message news:<slrnabeai4.lrg.huaiyu at gauss.almadan.ibm.com>...
> I need advice on how to handle the following situation:
>
> utils1.py:
> a
> b
> c
> if __name__ == '__main__':
> from interface import data_initialization # circular
[snip]
>From your description I'm not sure what the problem is. That import
is not actually circular because when utils1.py is imported from
another module, ( _name__ == '__main__' ) will be false, so the
import statement after it will not be executed.
Am I missing something?
Tom
More information about the Python-list
mailing list