Dict value not changing during when set

Viewed 24

while running the below code, calling .append or changing the values in the dict does not cause it to change. I can't figure out why, as I'm not iterating over the dict. Thanks for any help!

        events = map(parse_line, file_handle) 
for event in events:
            timestamp = event[1]
            url = event[2]
            user = event[3]
            key = timestamp.split("T")[0]+":" + timestamp.split("T")[1].split(":")[0]
            try:
                retdict[key].keys()
            except:
                retdict[key] = {"urls":{url:{'usrs':[user],'uniusrs':7}},'urlunis':1}
            else:
                if event[2] in retdict[key]['urls'].keys():
                    if event[3] in retdict[key]['urls'][url]['usrs']:
                        print("dupe")
                        continue
                    else:
                        print("Add to existing")
                        print(retdict[key]['urls'][url]['uniusrs'])
                        retdict[key]['urls'][url]['usrs'].append(user)
                        retdict[key]['urls'][url]['uniusrs'] = 231
                        print(retdict[key]['urls'][event[2]]['usrs'])
                        
                else:
                    retdict[key]['urls'][url] = {'usrs':[user],'uniusrs':1}

the Value for uniusrs is always 7, no matter what. But I know the else statement is being called, because the print("Add to existing") is still being called. Thanks for any help, yall.

0 Answers
Related