I have a base class which has a blank list as a class attribute. Many child classes inherit from this base class. The intent is to use this list class attribute in conjunction with a class method in order to allow each child class to keep track of a certain set of its own instances. Each class is supposed to have a separate list which contains only its own instances.
When I made a naive implementation of this inheritance scheme, durring debugging I noticed that in fact every single child class was sharing the exact same list as a class attribute, and I was once again having Fun with the fact that python passes lists by reference. On closer inspection, it seems like every class attribute of the parent, methods and values alike, is simply passed by reference to every child, and that this doesn't change unless a particular attribute is explicitly overridden in the definition of the child.
What is the best way to reinitialize the class variables of a child upon its creation? Ideally, I'd like a way to ensure that every child starts with a cls.instances attribute that is a unique blank list which involves NO extra code in any of the children. Otherwise, what am I bothering with inheritance for in the first place? (don't answer that)