Let's say I have 2 python script
the first one:
#X.py
import Y
a = 'list'
print('finish')
and the second one:
#Y.py
import X
z = X.a
print(z)
Question 1:
When I execute X.py first,there's nothing wrong with the code,but when I execute the Y.py first,an error occurs,but why?
Question 2:
I've looked up some answers for circular importing,but I still don't understand.In this case,starting from X.py,the first line is "import Y",then the program should goes to compile Y.py.The first line in Y.py is "import X",so I guess the program goes to X.py again,then goes to Y.py ,and so on..... But why there is no endless loop happens?
Thanks for the help!