Dec-28-2020, 04:52 PM
(Dec-25-2020, 12:44 AM)bowlofred Wrote:(Dec-25-2020, 12:00 AM)ptrivino Wrote: Thank you. The thing I am trying to fix is that when I do this in a third-level function:
for curr_id in dict_1: # loop through the dictionary # code code code dict_1[curr_id].incl_ips.append(ipaddress.ip_network(rng_chop[0] + "/" + str(myprefix), False)) # code code codeit appends the value in the loop iteration to THE SAME dictionary entry.
I'm not sure I follow this part. What are you expecting it to append to?
Quote:Also, from my OP, essentially dict_1_copy is discarded when I exit the function and recreated the next time the function is called?
Yes. I wouldn't use "discarded" here because the actual data remains (since it has another name outside the function). I would say it is "reassigned" the next time the function is called. No data is created at that time.
In the dict_1 entries I set the value to an object/class with 4 attributes (incl_ips is one of them), each a list of other values. But what doesn't work is that, in each loop through with a new curr_id, the SAME dictionary entry (or possibly ALL entries, I've seen that in another try)is updated/appended to.