I have a fundamental problem with a python class that I use in my scripts, that I will try to describe in the following example. Basically, I have one given class, let's call it test:
class test:
dic={}
def __init__(self,dic=dic):
self.dic=dic
To my class is attached a dictionary 'dic'. Sometimes I need to create two objects of that class, and then build their own dictionary separately. But my problem is that even if those two objects have different memory allocation, their dictionaries can have the same memory allocation:
v1=test()
v2=test()
# v1 and v2 objects have different id
print(id(v1),id(v2))
>> 140413717050928 140413717051040
# However, v1 and v2 properties have the same id
v1.dic['hello']=1
v2.dic['hello']=2
print(id(v1.dic['hello']),id(v2.dic['hello']))
>> 94431202597440 94431202597440
So I can not build my two objects separately:
print(v1.dic['hello'],v2.dic['hello'])
>> 2 2
This is a huge problem for me. How can I create two objects of this class that will have separate properties?