Advertisement
user_137

Untitled

Oct 5th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. class C:
  2.     def __init__(self, i, t, l):
  3.         print('before bindings')
  4.         print(i, type(i), id(i))
  5.         print(t, type(t), id(t))
  6.         print(l, type(l), id(l))
  7.         i = 1678
  8.         t = (1,2,3)
  9.         l[:] = [1,2,4,5]  # assign to a slice
  10.         print('after bindings')
  11.         print(i, type(i), id(i))
  12.         print(t, type(t), id(t))
  13.         print(l, type(l), id(l))
  14.     def assign_to_list(self):
  15.         l = [1,2,5]
  16.         print('in class, binding to list change object?')
  17.         print(l, type(l), id(l))
  18.  
  19. i, t, l = 1678, (1,2,3), [1,2,3]
  20. print(i, type(i), id(i))
  21. print(t, type(t), id(t))
  22. print(l, type(l), id(l))
  23. print('now initialize class')
  24. c = C(i, t, l)
  25. print("what's in them now")
  26. print(i, type(i), id(i))
  27. print(t, type(t), id(t))
  28. print(l, type(l), id(l))
  29. c.assign_to_list()
  30. print("what's in l after assign in class")
  31. print(l, type(l), id(l))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement