Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pickle
- class A:
- def __init__(self):
- pass
- class C:
- def __init__(self):
- print("deva")
- pass
- def a(self):
- print("yeah!")
- pass
- class B:
- def __init__(self):
- self.b = A.C()
- self.b1=1
- b = B()
- print ("ok, object created")
- my_pickled_b = pickle.dumps(b)
- print ("ok, object pickled, here it is...")
- print (my_pickled_b)
- print ("trying to unpickle it ...")
- c = pickle.loads(my_pickled_b)
- print ("unpickled! here it is:")
- print (c)
- print ("and this is the value of c.b1 : ")
- print (c.b1)
- c.b.a()
Add Comment
Please, Sign In to add comment