fork download
  1. import pickle
  2.  
  3. class A(object):
  4. def __init__(self, val):
  5. self.val = val
  6.  
  7. a = A(1)
  8. a_copy = pickle.loads(pickle.dumps(a))
  9.  
  10. print("a val = ", a.val)
  11. print("a_copy val = ", a_copy.val)
  12.  
  13. a.val = 10
  14. print("a val = ", a.val)
  15. print("a_copy val = ", a_copy.val)
  16.  
  17. a_copy.val = 25
  18. print("a val = ", a.val)
  19. print("a_copy val = ", a_copy.val)
  20.  
Success #stdin #stdout 0.04s 10352KB
stdin
Standard input is empty
stdout
a val =  1
a_copy val =  1
a val =  10
a_copy val =  1
a val =  10
a_copy val =  25