[Python] combining two dictionaries and still have the references to original objects in python

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have two dictionaries and I want to combine the contents of both in order to process them in a combined way. I do the following

    a = {'one': 'fileone', 'two': 'filetow'}
    b = {'three': 'filethree', 'four': 'filefour'}
    clist = a.values() + b.values()

    If I change anything in the clist, the change is not reflected in list a or b.


    One thing I understand is that the string is immutable type.

    I would still want to be able to refer to the old strings and changes to them must reflect in the original string.

    Thanks

    Continue reading...

Compartilhe esta Página