I'm trying to understand the behaviour of the pickle module.
It seems to me that pickle doesn't save methods, only attributes.
Here is what I mean with a code:
import pickle
class Person:
def __init__(self, name):
self.name = name
def add_dot(self):
self.name += '.'
etienne = Person('etienne')
pickled = pickle.dumps(etienne)
class Person:
def __init__(self, name):
self.name = name
def add_dot(self):
self.name += '..'
etienne = pickle.loads(pickled)
etienne.add_dot()
What would you expect this code to return?
Is someone able to explain me this behaviour?