Importing a py file within itself
问题 This is test.py: import sys a = 50 b = [1,2] def change(): print "Here 1" import test print "Here 2" test.a = -1 test.b = [0,1] return def main(): print "Here 3" change() print "Here 4" print a, b if 1: main() The above python code when ran on system generates the following output: Here 3 Here 1 Here 3 Here 1 Here 2 Here 4 -1 [0, 1] Here 2 Here 4 50 [1, 2] What I am confused why is not there an infinite loop of "Here 1 \n Here 3" outputs. How can the print a, b outputs can be justified? 回答1: