I tried to store a dictionary template at the beginning of my code that most of the functions will use:
- Dictionary: keys = Client name, values = Dictionary2
- Dictionary2: keys = User name, values = None
I filled it with all our clients and their users. Then each part of the code can copy this dictionary and produces it's owns outputs. The goal is that each output will have the same "base" dictionary structure like a template where None can be modified.
For each process using this dictionnary I use the following :
process1dict = clientdict
# processing 1
output1dict = ... #modified version of original clientdict, the None values have been replaced by dictionaries/lists
process2dict = clientdict
# processing 2
output2dict = ... #same here but could be different
The problem that I have is that the cliendict changes each time it is copied into a process!
I noticed that because of the None
value in my initial cliendict
it changes after each process (depending on the output of each one of course).
Edit: I found the copy library but copy()
seems to not help my case. I will try out the deepcopy() but why did copy()
didn't worked? And why deepcopy()
will?