Strange Result about Module circular rreference

CFAN eyelinux at
Sun Feb 3 01:59:07 CET 2008

First Set up the following files,
#Module A
import m2
var1 = "ModuleM1"
#Module B
import m3
var1 = "ModuleM2"
#Module C
import m1
var1 =  "ModuleM3"
import m3
print m3.var1
print m3.m1.var1
print m3.m1.m2.var1
print m3.m1.m2.m3.var1

Then to run
the result is :

Traceback (most recent call last):
  File "D:\WorkTools\ActivePython\Lib\site-packages\pythonwin\pywin
\framework\", line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Documents and Settings\yoyo\My Documents\", line
5, in ?
    print m3.m1.m2.m3.var1
AttributeError: 'module' object has no attribute 'm3'

,can any one explain it, this test is inspired by Python Programming
which says that the moudle can reference in
the circular manner, and I got wired about it and then try this test.
the result that 'module' object has no attribute 'm3' seems okay ,if i
assumes that import only import a module once, but how about the reult
"ModuleA "  and even "8" ?

More information about the Python-list mailing list