Diffrent results: (in python shell) import t1 and (in command-line) python t1.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---FILE: t1.py---
print "[MODULE:", __name__, "]"
print "\t--> X = 1"
X = 1
print "\timport t2"
import t2
print "\t--> Y = 2"
Y = 2
print "\tmodule:", __name__, "X", X
print "\tmodule:", __name__, "Y", Y
print "[END MODULE:", __name__, "]"
---END OF FILE: t1.py---
---FILE: t2.py---
print "[MODULE:", __name__, "]"
print "\timport t1"
import t1
print "\t--> t1.X = 3"
t1.X = 3
print "\t--> t1.Y = 4"
t1.Y = 4
print "\tmodule:", __name__, "X", t1.X
print "\tmodule:", __name__, "Y", t1.Y
print "[END MODULE:", __name__, "]"
---END OF FILE: t2.py---