When calling on a new instance of an object for a class I've created, my one instance of the class is just being overwritten. Why could this be? Example is below.
My class is defined as follows:
class my_class: attribute = "" examples = [] children = [] d = {} def __init__(self, attribute, e): self.attribute = attribute self.examples = e for ex in self.examples: self.d[ex[-1]] = self.d.get(ex[-1], 0) + 1 I am making an initial instance as such:
root = my_class(some_attribute, data) Then, I create another instance as such:
child = my_class(different_attribute, root.examples[somewhere_1:somewhere_2]) In the end, my initial 'root' is now somehow identical to 'child', where 'root' should have gone unchanged. Why is this!?