Answer the question
In order to leave comments, you need to log in
How can I prevent a child object from referencing a parent object?
My problem is that the created object inside the class refers to the object that created it. How to fix ?
import copy as cp
class a():
lis = []
def create_a(self):
obj = cp.copy(a())
print(obj.lis is self.lis) # True
b = a()
b.create_a()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question