how can i make a change to a global dictionary while looping on lists of dictionaries?

The issue is you need to reset the elements of the global dictionary without creating a new object.

Try this update:

    if xmlsnip != '':
        #  What I'd lik eto do is assign to the global list:
        my_list_old.clear()  # remove existing entries
        my_list_old.update(my_list)  # add new entries, keep object pointer
        # but it only assigns to the local variable, not the global one I 'pointed' to

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top