1 def f(): 2 l = [1, 2, 3] 3 x = l 4 a, b, c = l 5 d, e, f = [1, 2, 3] 6 print a, b, c # 1, 2, 3 7 print d, e, f # 1, 2, 3 8 print x # [1, 2, 3] 9 10 def g(x): 11 l = [1, 2, 3] 12 m = [4, l, 6] 13 if x: 14 n = l 15 else: 16 n = m 17 print n 18 19 def h(): 20 return 7, 8, 9 21 22 def i(): 23 a, b, c = h() 24 print a, b, c 25 26 # Test assignment operations within functions. 27 28 f() 29 g(0) # [4, [1, 2, 3], 6] 30 g(1) # [1, 2, 3] 31 32 # Test aliasing, assignment of list elements and direct assignment of elements. 33 34 l = [1, 2, 3] 35 x = l 36 a, b, c = l 37 d, e, f = [1, 2, 3] 38 39 print a, b, c # 1 2 3 40 print d, e, f # 1 2 3 41 print x # [1, 2, 3] 42 43 # Test embedding of sequences in sequences. 44 45 m = [4, l, 6] 46 47 # Test sequence truth value interpretation. 48 49 if x: 50 n = l 51 else: 52 n = m 53 54 print n # [1, 2, 3] 55 56 # Test temporary variable usage at module level. 57 58 a, b, c = h() 59 print a, b, c # 7 8 9 60 61 # Test temporary variable usage in functions. 62 63 i() # 7 8 9 64 65 # Test temporary variable usage in classes. 66 67 class C: 68 a, b, c = h() 69 print a, b, c # 7 8 9