I have a class that contains a list of elements, each instance of a class contains a different type of element in the list (mainly floats and strings), the structure resembles the code below:
class series:
...
data = []
...
When I create a number of this classes it seems that they point to the same address in memory, so when I append data to the list of one of the objects, all the objects have the same items in their respective lists and this behaviour could result problematic.
The workaround that I found in this article is to use the copy
Object during the initialization of my series
Object (see code below).
class series:
...
data = []
...
def __init__(self):
...
self.data = copy.copy(self.data)
Is there a more elegant solution?