1 class C: 2 def m(self): 3 return 1 4 5 D = C # alias for C 6 7 print C # __main__.C 8 print D # __main__.C 9 10 class E: 11 def m(self): 12 return 2 13 14 F = E # alias for E 15 16 print E # __main__.E 17 print F # __main__.E 18 19 def f(): 20 c = C 21 d = D # C 22 cm = C.m 23 dm = D.m # C.m 24 25 print c # __main__.C 26 print d # __main__.C 27 print cm # __main__.C.m 28 print dm # __main__.C.m 29 30 c = E 31 d = F # E 32 cm = E.m 33 dm = F.m # E.m 34 35 print c # __main__.E 36 print d # __main__.E 37 print cm # __main__.E.m 38 print dm # __main__.E.m 39 40 f() 41 42 Cm = C.m 43 Dm = D.m 44 Em = E.m 45 Fm = F.m 46 47 print Cm # __main__.C.m 48 print Dm # __main__.C.m 49 print Em # __main__.E.m 50 print Fm # __main__.E.m 51 52 def g(): 53 Cm = E.m 54 Dm = F.m # E.m 55 56 print Cm # __main__.E.m 57 print Dm # __main__.E.m 58 59 g() 60 61 def h(): 62 global Em, Fm 63 Em = C.m 64 Fm = D.m # C.m 65 66 print Em # __main__.C.m 67 print Fm # __main__.C.m 68 69 h() 70 71 print Em # __main__.C.m 72 print Fm # __main__.C.m 73 74 Ci = C() 75 Ei = E() 76 77 print Ci # <__main__.C instance> 78 print Ei # <__main__.E instance> 79 80 def i(): 81 c = Ci 82 print c # <__main__.C instance> 83 c = Ei 84 print c # <__main__.E instance> 85 86 i() 87 88 def j(): 89 global Ei 90 Ei = C() 91 print Ei # <__main__.C instance> 92 93 j() 94 95 print Ei # <__main__.C instance> 96 97 L = [] 98 M = [1] 99 100 print L # [] 101 print M # [1] 102 103 def k(): 104 c = L 105 print c # [] 106 107 k() 108 109 def l(): 110 global M 111 M = [] 112 print M # [] 113 114 l() 115 print M # []