I have a class where one of the methods is to replace the entire data encapsulate in the object when needed. However, I am not sure how to write the update the data to the object. Is it possible to assign the instance to the new instance, maybe something like self=new_self? I am aware I can create a new instance and then change the ptr to point to it, but would like to check if I can just update the same instance instead.
class Dictionary:
def __init__(self, collection_size):
self.dictionary = [Term() for _ in range(collection_size)]
self.collection_size = collection_size
def load(self, src):
with open(src, 'rb') as handle:
self = pickle.load(handle) # this is the part that needs editing